mirror of
https://github.com/Icinga/icingaweb2-module-graphite.git
synced 2026-06-07 15:52:09 -04:00
commit
1f0fb9d760
6 changed files with 90 additions and 2 deletions
39
application/controllers/GraphDummyController.php
Normal file
39
application/controllers/GraphDummyController.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Graphite\Controllers;
|
||||
|
||||
use Icinga\Module\Graphite\Web\Controller\MonitoringAwareController;
|
||||
|
||||
class GraphDummyController extends MonitoringAwareController
|
||||
{
|
||||
public function hostAction()
|
||||
{
|
||||
$this->supplyImage();
|
||||
}
|
||||
|
||||
public function serviceAction()
|
||||
{
|
||||
$this->supplyImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do all monitored object type independend actions
|
||||
*/
|
||||
protected function supplyImage()
|
||||
{
|
||||
$this->getResponse()
|
||||
->setHeader('Content-Type', 'image/png', true)
|
||||
->setHeader('Content-Disposition', 'inline; filename="dummy.png"', true)
|
||||
->setBody(
|
||||
"\x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\x00\x00\x01"
|
||||
. "\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\x06bKG"
|
||||
. "D\x00\xff\x00\xff\x00\xff\xa0\xbd\xa7\x93\x00\x00\x00\x09pHYs\x00"
|
||||
. "\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x0bIDAT"
|
||||
. "\x08\xd7c`\x00\x02\x00\x00\x05\x00\x01\xe2&\x05\x9b\x00\x00\x00\x00I"
|
||||
. "END\xaeB`\x82"
|
||||
)
|
||||
->sendResponse();
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ class DetailviewExtension extends DetailviewExtensionHook
|
|||
->setWidth(440)
|
||||
->setHeight(220)
|
||||
->setClasses(['monitored-object-detail-view'])
|
||||
->setPreloadDummy()
|
||||
->handleRequest();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,13 @@ abstract class Graphs extends AbstractWidget
|
|||
*/
|
||||
protected $classes = [];
|
||||
|
||||
/**
|
||||
* Whether to serve a transparent dummy image first and let the JS code load the actual graph
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $preloadDummy = false;
|
||||
|
||||
/**
|
||||
* Factory, based on the given object
|
||||
*
|
||||
|
|
@ -147,7 +154,7 @@ abstract class Graphs extends AbstractWidget
|
|||
$view = $this->view();
|
||||
$result = []; // kind of string builder
|
||||
$filter = $this->getMonitoredObjectFilter();
|
||||
$imageBaseUrl = $this->getImageBaseUrl();
|
||||
$imageBaseUrl = $this->preloadDummy ? $this->getDummyImageBaseUrl() : $this->getImageBaseUrl();
|
||||
$templates = static::getAllTemplates()->getTemplates();
|
||||
$checkCommand = $this->obscuredCheckCommand === null ? $this->checkCommand : $this->obscuredCheckCommand;
|
||||
|
||||
|
|
@ -234,6 +241,13 @@ abstract class Graphs extends AbstractWidget
|
|||
*/
|
||||
abstract protected function getImageBaseUrl();
|
||||
|
||||
/**
|
||||
* Get the base URL to a dummy image specifying just the monitored object kind
|
||||
*
|
||||
* @return Url
|
||||
*/
|
||||
abstract protected function getDummyImageBaseUrl();
|
||||
|
||||
/**
|
||||
* Extend the {@link getImageBaseUrl()}'s result's parameters with the concrete monitored object
|
||||
*
|
||||
|
|
@ -337,4 +351,28 @@ abstract class Graphs extends AbstractWidget
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether to serve a transparent dummy image first and let the JS code load the actual graph
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getPreloadDummy()
|
||||
{
|
||||
return $this->preloadDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to serve a transparent dummy image first and let the JS code load the actual graph
|
||||
*
|
||||
* @param bool $preloadDummy
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPreloadDummy($preloadDummy = true)
|
||||
{
|
||||
$this->preloadDummy = $preloadDummy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ class Host extends Graphs
|
|||
return Url::fromPath('graphite/graph/host');
|
||||
}
|
||||
|
||||
protected function getDummyImageBaseUrl()
|
||||
{
|
||||
return Url::fromPath('graphite/graph-dummy/host');
|
||||
}
|
||||
|
||||
protected function filterImageUrl(Url $url)
|
||||
{
|
||||
return $url->setParam('host.name', $this->host);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@ class Service extends Graphs
|
|||
return Url::fromPath('graphite/graph/service');
|
||||
}
|
||||
|
||||
protected function getDummyImageBaseUrl()
|
||||
{
|
||||
return Url::fromPath('graphite/graph-dummy/service');
|
||||
}
|
||||
|
||||
protected function filterImageUrl(Url $url)
|
||||
{
|
||||
return $url->setParam('host.name', $this->host)->setParam('service.name', $this->service);
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@
|
|||
renderedUrlParams.push(urlParam + "=" + urlParams[urlParam]);
|
||||
}
|
||||
|
||||
e.attr("src", matchParams[1] + "?" + renderedUrlParams.join("&"));
|
||||
e.attr("src", matchParams[1].replace("-dummy", "") + "?" + renderedUrlParams.join("&"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue