2017-09-19 11:18:40 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Icinga\Module\Graphite\Web\Widget\Graphs;
|
|
|
|
|
|
2017-09-28 12:56:16 -04:00
|
|
|
use Icinga\Module\Graphite\Graphing\Template;
|
2017-09-19 11:18:40 -04:00
|
|
|
use Icinga\Module\Graphite\Web\Widget\Graphs;
|
2017-09-21 11:03:05 -04:00
|
|
|
use Icinga\Web\Url;
|
2017-09-19 11:18:40 -04:00
|
|
|
|
|
|
|
|
class Service extends Graphs
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The host to render the graphs of
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $host;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The service to render the graphs of
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $service;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*
|
2017-10-06 11:03:45 -04:00
|
|
|
* @param string $host The host to render the graphs of
|
|
|
|
|
* @param string $service The service to render the graphs of
|
|
|
|
|
* @param string $checkCommand The check command of the monitored object we display graphs for
|
|
|
|
|
* @param string|null $obscuredCheckCommand The "real" check command (if any) of the monitored object
|
|
|
|
|
* we display graphs for
|
2017-09-19 11:18:40 -04:00
|
|
|
*/
|
2017-10-06 11:03:45 -04:00
|
|
|
public function __construct($host, $service, $checkCommand, $obscuredCheckCommand)
|
2017-09-19 11:18:40 -04:00
|
|
|
{
|
2017-10-06 11:03:45 -04:00
|
|
|
parent::__construct($checkCommand, $obscuredCheckCommand);
|
2017-09-29 11:36:46 -04:00
|
|
|
|
2017-09-19 11:18:40 -04:00
|
|
|
$this->host = $host;
|
|
|
|
|
$this->service = $service;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-28 12:56:16 -04:00
|
|
|
protected function getImageBaseUrl()
|
2017-09-19 11:18:40 -04:00
|
|
|
{
|
2017-09-28 12:56:16 -04:00
|
|
|
return Url::fromPath('graphite/graph/service');
|
2017-09-19 11:18:40 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-19 12:00:19 -04:00
|
|
|
protected function getDummyImageBaseUrl()
|
|
|
|
|
{
|
|
|
|
|
return Url::fromPath('graphite/graph-dummy/service');
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-28 12:56:16 -04:00
|
|
|
protected function filterImageUrl(Url $url)
|
2017-09-19 11:18:40 -04:00
|
|
|
{
|
2017-09-28 12:56:16 -04:00
|
|
|
return $url->setParam('host.name', $this->host)->setParam('service.name', $this->service);
|
2017-09-19 11:18:40 -04:00
|
|
|
}
|
2017-09-21 11:03:05 -04:00
|
|
|
|
2017-09-28 12:56:16 -04:00
|
|
|
protected function designedForMyMonitoredObjectType(Template $template)
|
2017-09-21 11:03:05 -04:00
|
|
|
{
|
2017-09-28 12:56:16 -04:00
|
|
|
foreach ($template->getCurves() as $curve) {
|
2017-10-06 11:27:50 -04:00
|
|
|
if (in_array('service_name_template', $curve[0]->getMacros())) {
|
2017-09-28 12:56:16 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2017-09-21 11:03:05 -04:00
|
|
|
}
|
2017-09-22 05:55:46 -04:00
|
|
|
|
2017-09-28 12:56:16 -04:00
|
|
|
protected function getMonitoredObjectFilter()
|
2017-09-22 05:55:46 -04:00
|
|
|
{
|
2017-09-28 12:56:16 -04:00
|
|
|
return ['host.name' => $this->host, 'service.name' => $this->service];
|
2017-09-22 05:55:46 -04:00
|
|
|
}
|
2017-09-19 11:18:40 -04:00
|
|
|
}
|