mirror of
https://github.com/Icinga/icingaweb2-module-graphite.git
synced 2026-04-22 14:47:23 -04:00
show/graph: new action for proxied images
This commit is contained in:
parent
06b91da0fa
commit
d372a4e798
2 changed files with 41 additions and 0 deletions
|
|
@ -126,6 +126,46 @@ class ShowController extends Controller
|
|||
$this->view->images = $imgs;
|
||||
}
|
||||
|
||||
public function graphAction()
|
||||
{
|
||||
$base = $this->Config()->get('global', 'host_pattern');
|
||||
|
||||
$template = $this->loadTemplate($this->params->shift('template'));
|
||||
$start = $this->params->shift('start', '-1hours');
|
||||
$width = $this->params->shift('width', '300');
|
||||
$height = $this->params->shift('height', '150');
|
||||
|
||||
$title = $template->getTitle();
|
||||
if (false === strpos($title, '$')) {
|
||||
$template->setTitle('$hostname');
|
||||
} else {
|
||||
if (false === strpos($title, '$hostname')) {
|
||||
$template->setTitle('$hostname: ' . $template->getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
$query = $this->graphiteWeb
|
||||
->select()
|
||||
->from(
|
||||
array('host' => $base),
|
||||
$template->getFilterString()
|
||||
);
|
||||
|
||||
foreach ($this->params->toArray() as $val) {
|
||||
$query->where($val[0], $val[1]);
|
||||
}
|
||||
|
||||
$img = current($query->getImages($template));
|
||||
|
||||
$img->setStart($start)
|
||||
->setWidth($width)
|
||||
->setHeight($height)
|
||||
->showLegend(false);
|
||||
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->view->image = $img->fetchImage();
|
||||
}
|
||||
|
||||
public function hostAction()
|
||||
{
|
||||
$hostname = $this->view->hostname = $this->params->get('host');
|
||||
|
|
|
|||
1
application/views/scripts/show/graph.phtml
Normal file
1
application/views/scripts/show/graph.phtml
Normal file
|
|
@ -0,0 +1 @@
|
|||
<?= $this->image ?>
|
||||
Loading…
Reference in a new issue