show/graph: new action for proxied images

This commit is contained in:
Thomas Gelf 2016-02-10 20:18:04 +01:00
parent 06b91da0fa
commit d372a4e798
2 changed files with 41 additions and 0 deletions

View file

@ -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');

View file

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