public function getPreviewHtml(MonitoredObject $object) { $perfdata_property = $object->getType() . "_process_perfdata"; if (!$object->{$perfdata_property}) { return ''; } $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()); } }
public function getPreviewHtml(MonitoredObject $object) { $perfdata_property = $object->getType() . "_process_perfdata"; if (!$object->{$perfdata_property}) { return ''; } $object->fetchCustomvars(); if (array_key_exists("graphite", $object->customvars)) { $this->parseGrapherConfig($object->customvars["graphite"]); $this->getKeysAndLabels($object->customvars["graphite"], $object->customvars); } else { $this->getKeysAndLabels(array(), $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; }