public function getPreviewHtml(MonitoredObject $object)
 {
     $object->fetchCustomvars();
     if (array_key_exists("graphite_keys", $object->customvars)) {
         $graphiteKeys = $object->customvars["graphite_keys"];
     } else {
         $graphiteKeys = array();
         foreach (PerfdataSet::fromString($object->perfdata)->asArray() as $pd) {
             $graphiteKeys[] = $pd->getLabel();
         }
     }
     if ($object instanceof Host) {
         $host = $object;
         $service = null;
     } elseif ($object instanceof Service) {
         $service = $object;
         $host = null;
     } else {
         return '';
     }
     $html = "<table class=\"avp newsection\">\n" . "<tbody>\n";
     foreach ($graphiteKeys as $metric) {
         $html .= "<tr><th>\n" . "{$metric}\n" . '</th><td>' . $this->getPreviewImage($host, $service, $metric) . "</td>\n" . "<tr>\n";
     }
     $html .= "</tbody></table>\n";
     return $html;
 }
 /**
  * Apply filter to query data
  *
  * @param   array           $data
  * @param   MonitoredObject $object
  *
  * @return  array
  */
 protected function applyFilter(array &$data, MonitoredObject $object)
 {
     if ($object->getType() === $object::TYPE_HOST) {
         /** @var \Icinga\Module\Monitoring\Object\Host $object */
         $data['host'] = $object->getName();
     } else {
         /** @var \Icinga\Module\Monitoring\Object\Service $object */
         $data['service'] = sprintf('%s!%s', $object->getHost()->getName(), $object->getName());
     }
 }
Beispiel #3
0
 /**
  * Get all action urls configured for this monitored object
  *
  * @return array    All note urls as a string
  */
 public function getActionUrls()
 {
     return $this->resolveAllStrings(MonitoredObject::parseAttributeUrls($this->action_url));
 }
 public function getPreviewHtml(MonitoredObject $object)
 {
     $object->fetchCustomvars();
     if (array_key_exists("graphite", $object->customvars)) {
         $this->parseGrapherConfig($object->customvars["graphite"]);
     }
     $this->getKeysAndLabels($object->customvars);
     if (empty($this->graphiteKeys)) {
         $this->getPerfDataKeys($object);
     }
     if ($object instanceof Host) {
         $host = $object;
         $service = null;
     } elseif ($object instanceof Service) {
         $service = $object;
         $host = null;
     } else {
         return '';
     }
     $html = "<table class=\"avp newsection\">\n" . "<tbody>\n";
     for ($key = 0; $key < count($this->graphiteKeys); $key++) {
         $html .= "<tr><th>\n" . $this->graphiteLabels[$key] . '</th><td>' . $this->getPreviewImage($host, $service, $this->graphiteKeys[$key]) . "</td>\n" . "<tr>\n";
     }
     $html .= "</tbody></table>\n";
     return $html;
 }
Beispiel #5
0
 public function getNotesUrls()
 {
     return $this->resolveAllStrings(MonitoredObject::parseAttributeUrls($this->host_notes_url));
 }
Beispiel #6
0
 /**
  * Set the involved object
  *
  * @param   MonitoredObject $object
  *
  * @return  $this
  */
 public function setObject(MonitoredObject $object)
 {
     $object->assertOneOf($this->allowedObjects);
     $this->object = $object;
     return $this;
 }