Hook\Grapher: use it in monitoring/show

This commit is contained in:
Thomas Gelf 2014-06-21 04:13:14 +02:00
parent 2ab75e1433
commit 7f53ba11cf
4 changed files with 21 additions and 5 deletions

View File

@ -51,6 +51,8 @@ class Monitoring_ShowController extends Controller
*/ */
protected $backend; protected $backend;
protected $grapher;
/** /**
* Initialize the controller * Initialize the controller
*/ */
@ -67,6 +69,9 @@ class Monitoring_ShowController extends Controller
if (Hook::has('ticket')) { if (Hook::has('ticket')) {
$this->view->tickets = Hook::first('ticket'); $this->view->tickets = Hook::first('ticket');
} }
if (Hook::has('grapher')) {
$this->grapher = Hook::first('grapher');
}
$this->createTabs(); $this->createTabs();
} }
@ -76,11 +81,15 @@ class Monitoring_ShowController extends Controller
*/ */
public function serviceAction() public function serviceAction()
{ {
$o = $this->view->object;
$this->setAutorefreshInterval(10); $this->setAutorefreshInterval(10);
$this->view->title = $this->view->object->service_description $this->view->title = $o->service_description
. ' on ' . $this->view->object->host_name; . ' on ' . $o->host_name;
$this->getTabs()->activate('service'); $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() public function hostAction()
{ {
$o = $this->view->object;
$this->setAutorefreshInterval(10); $this->setAutorefreshInterval(10);
$this->getTabs()->activate('host'); $this->getTabs()->activate('host');
$this->view->title = $this->view->object->host_name; $this->view->title = $o->host_name;
$this->view->object->populate(); $o->populate();
if ($this->grapher && $this->grapher->hasGraph($o->host_name)) {
$this->view->grapherHtml = $this->grapher->getPreviewImage($o->host_name);
}
} }
public function historyAction() public function historyAction()

View File

@ -0,0 +1 @@
<?= $this->grapherHtml ?>

View File

@ -4,6 +4,7 @@
</div> </div>
<div class="content" data-base-target="_next"> <div class="content" data-base-target="_next">
<?= $this->render('show/components/output.phtml') ?> <?= $this->render('show/components/output.phtml') ?>
<?= $this->render('show/components/grapher.phtml') ?>
<table class="avp newsection"> <table class="avp newsection">
<tbody> <tbody>

View File

@ -4,6 +4,7 @@
</div> </div>
<div class="content" data-base-target="_next"> <div class="content" data-base-target="_next">
<?= $this->render('show/components/output.phtml') ?> <?= $this->render('show/components/output.phtml') ?>
<?= $this->render('show/components/grapher.phtml') ?>
<table class="avp newsection"> <table class="avp newsection">
<tbody> <tbody>