summaryrefslogtreecommitdiffstats
path: root/library/Graphite/Web/Widget/Graphs
diff options
context:
space:
mode:
Diffstat (limited to 'library/Graphite/Web/Widget/Graphs')
-rw-r--r--library/Graphite/Web/Widget/Graphs/Host.php51
-rw-r--r--library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php61
-rw-r--r--library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbService.php71
-rw-r--r--library/Graphite/Web/Widget/Graphs/Service.php56
4 files changed, 239 insertions, 0 deletions
diff --git a/library/Graphite/Web/Widget/Graphs/Host.php b/library/Graphite/Web/Widget/Graphs/Host.php
new file mode 100644
index 0000000..2247bcc
--- /dev/null
+++ b/library/Graphite/Web/Widget/Graphs/Host.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Icinga\Module\Graphite\Web\Widget\Graphs;
+
+use Icinga\Module\Graphite\Graphing\Template;
+use Icinga\Module\Graphite\Web\Widget\Graphs;
+use Icinga\Module\Monitoring\Object\Host as MonitoredHost;
+use Icinga\Web\Url;
+
+class Host extends Graphs
+{
+ protected $objectType = 'host';
+
+ /**
+ * The host to render the graphs of
+ *
+ * @var MonitoredHost
+ */
+ protected $object;
+
+ protected function getImageBaseUrl()
+ {
+ return Url::fromPath('graphite/graph/host');
+ }
+
+ protected function getGraphsListBaseUrl()
+ {
+ return Url::fromPath('graphite/list/hosts', ['host' => $this->object->getName()]);
+ }
+
+ protected function filterImageUrl(Url $url)
+ {
+ return $url->setParam('host.name', $this->object->getName());
+ }
+
+ protected function getMonitoredObjectIdentifier()
+ {
+ return $this->object->getName();
+ }
+
+ protected function designedForObjectType(Template $template)
+ {
+ foreach ($template->getCurves() as $curve) {
+ if (in_array('host_name_template', $curve[0]->getMacros())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php b/library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php
new file mode 100644
index 0000000..2b0a614
--- /dev/null
+++ b/library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Icinga\Module\Graphite\Web\Widget\Graphs\Icingadb;
+
+use Icinga\Module\Graphite\Graphing\Template;
+use Icinga\Module\Graphite\Web\Widget\Graphs;
+use Icinga\Web\Url;
+use Icinga\Module\Icingadb\Model\Host;
+
+class IcingadbHost extends Graphs
+{
+ protected $objectType = 'host';
+
+ /**
+ * The Icingadb host to render the graphs for
+ *
+ * @var Host
+ */
+ protected $object;
+
+ protected function getGraphsListBaseUrl()
+ {
+ return Url::fromPath('graphite/hosts', ['host.name' => $this->object->name]);
+ }
+
+ protected function filterImageUrl(Url $url)
+ {
+ return $url->setParam('host.name', $this->object->name);
+ }
+
+ public function createHostTitle()
+ {
+ return $this->object->name;
+ }
+
+ public function getObjectType()
+ {
+ return $this->objectType;
+ }
+
+ protected function getMonitoredObjectIdentifier()
+ {
+ return $this->object->name;
+ }
+
+ protected function getImageBaseUrl()
+ {
+ return Url::fromPath('graphite/graph/host');
+ }
+
+ protected function designedForObjectType(Template $template)
+ {
+ foreach ($template->getCurves() as $curve) {
+ if (in_array('host_name_template', $curve[0]->getMacros())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbService.php b/library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbService.php
new file mode 100644
index 0000000..7827e86
--- /dev/null
+++ b/library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbService.php
@@ -0,0 +1,71 @@
+<?php
+
+namespace Icinga\Module\Graphite\Web\Widget\Graphs\Icingadb;
+
+use Icinga\Module\Graphite\Graphing\Template;
+use Icinga\Module\Graphite\Web\Widget\Graphs;
+use Icinga\Web\Url;
+use Icinga\Module\Icingadb\Model\Service;
+
+class IcingadbService extends Graphs
+{
+ protected $objectType = 'service';
+
+ /**
+ * The icingadb service to render the graphs for
+ *
+ * @var Service
+ */
+ protected $object;
+
+ protected function getGraphsListBaseUrl()
+ {
+ return Url::fromPath(
+ 'graphite/services',
+ ['service.name' => $this->object->name, 'host.name' => $this->object->host->name]
+ );
+ }
+
+ protected function filterImageUrl(Url $url)
+ {
+ return $url
+ ->setParam('host.name', $this->object->host->name)
+ ->setParam('service.name', $this->object->name);
+ }
+
+ public function createHostTitle()
+ {
+ return $this->object->host->name;
+ }
+
+ public function createServiceTitle()
+ {
+ return ' : ' . $this->object->name;
+ }
+
+ public function getObjectType()
+ {
+ return $this->objectType;
+ }
+
+ protected function getMonitoredObjectIdentifier()
+ {
+ return $this->object->host->name . ':' . $this->object->name;
+ }
+
+ protected function getImageBaseUrl()
+ {
+ return Url::fromPath('graphite/graph/service');
+ }
+
+ protected function designedforObjectType(Template $template)
+ {
+ foreach ($template->getCurves() as $curve) {
+ if (in_array('service_name_template', $curve[0]->getMacros())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/library/Graphite/Web/Widget/Graphs/Service.php b/library/Graphite/Web/Widget/Graphs/Service.php
new file mode 100644
index 0000000..5fc0143
--- /dev/null
+++ b/library/Graphite/Web/Widget/Graphs/Service.php
@@ -0,0 +1,56 @@
+<?php
+
+namespace Icinga\Module\Graphite\Web\Widget\Graphs;
+
+use Icinga\Module\Graphite\Graphing\Template;
+use Icinga\Module\Graphite\Web\Widget\Graphs;
+use Icinga\Module\Monitoring\Object\Service as MonitoredService;
+use Icinga\Web\Url;
+
+class Service extends Graphs
+{
+ protected $objectType = 'service';
+
+ /**
+ * The service to render the graphs for
+ *
+ * @var MonitoredService
+ */
+ protected $object;
+
+ protected function getImageBaseUrl()
+ {
+ return Url::fromPath('graphite/graph/service');
+ }
+
+ protected function getGraphsListBaseUrl()
+ {
+ return Url::fromPath(
+ 'graphite/list/services',
+ ['host' => $this->object->getHost()->getName(), 'service' => $this->object->getName()]
+ );
+ }
+
+ protected function filterImageUrl(Url $url)
+ {
+ return $url
+ ->setParam('host.name', $this->object->getHost()->getName())
+ ->setParam('service.name', $this->object->getName());
+ }
+
+ protected function getMonitoredObjectIdentifier()
+ {
+ return $this->object->getHost()->getName() . ':' . $this->object->getName();
+ }
+
+ protected function designedForObjectType(Template $template)
+ {
+ foreach ($template->getCurves() as $curve) {
+ if (in_array('service_name_template', $curve[0]->getMacros())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}