From 7f53ba11cf632dbb6e6dfd2a0f90ae9c2627fccb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 21 Jun 2014 04:13:14 +0200 Subject: [PATCH] Hook\Grapher: use it in monitoring/show --- .../controllers/ShowController.php | 23 +++++++++++++++---- .../scripts/show/components/grapher.phtml | 1 + .../application/views/scripts/show/host.phtml | 1 + .../views/scripts/show/service.phtml | 1 + 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/show/components/grapher.phtml diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index a9db913db..3ef40d2bd 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -51,6 +51,8 @@ class Monitoring_ShowController extends Controller */ protected $backend; + protected $grapher; + /** * Initialize the controller */ @@ -67,6 +69,9 @@ class Monitoring_ShowController extends Controller if (Hook::has('ticket')) { $this->view->tickets = Hook::first('ticket'); } + if (Hook::has('grapher')) { + $this->grapher = Hook::first('grapher'); + } $this->createTabs(); } @@ -76,11 +81,15 @@ class Monitoring_ShowController extends Controller */ public function serviceAction() { + $o = $this->view->object; $this->setAutorefreshInterval(10); - $this->view->title = $this->view->object->service_description - . ' on ' . $this->view->object->host_name; + $this->view->title = $o->service_description + . ' on ' . $o->host_name; $this->getTabs()->activate('service'); - $this->view->object->populate(); + $o->populate(); + if ($this->grapher && $this->grapher->hasGraph($o->host_name, $o->service_description)) { + $this->view->grapherHtml = $this->grapher->getPreviewImage($o->host_name, $o->service_description); + } } /** @@ -88,10 +97,14 @@ class Monitoring_ShowController extends Controller */ public function hostAction() { + $o = $this->view->object; $this->setAutorefreshInterval(10); $this->getTabs()->activate('host'); - $this->view->title = $this->view->object->host_name; - $this->view->object->populate(); + $this->view->title = $o->host_name; + $o->populate(); + if ($this->grapher && $this->grapher->hasGraph($o->host_name)) { + $this->view->grapherHtml = $this->grapher->getPreviewImage($o->host_name); + } } public function historyAction() diff --git a/modules/monitoring/application/views/scripts/show/components/grapher.phtml b/modules/monitoring/application/views/scripts/show/components/grapher.phtml new file mode 100644 index 000000000..2d8d3e4bd --- /dev/null +++ b/modules/monitoring/application/views/scripts/show/components/grapher.phtml @@ -0,0 +1 @@ +grapherHtml ?> diff --git a/modules/monitoring/application/views/scripts/show/host.phtml b/modules/monitoring/application/views/scripts/show/host.phtml index e2f6ee1c4..da93bd8e6 100644 --- a/modules/monitoring/application/views/scripts/show/host.phtml +++ b/modules/monitoring/application/views/scripts/show/host.phtml @@ -4,6 +4,7 @@
render('show/components/output.phtml') ?> +render('show/components/grapher.phtml') ?> diff --git a/modules/monitoring/application/views/scripts/show/service.phtml b/modules/monitoring/application/views/scripts/show/service.phtml index 19e5666e2..b710a813f 100644 --- a/modules/monitoring/application/views/scripts/show/service.phtml +++ b/modules/monitoring/application/views/scripts/show/service.phtml @@ -4,6 +4,7 @@
render('show/components/output.phtml') ?> +render('show/components/grapher.phtml') ?>