diff --git a/library/Graphite/Web/Widget/Graphs.php b/library/Graphite/Web/Widget/Graphs.php index 97a5739..f4dac03 100644 --- a/library/Graphite/Web/Widget/Graphs.php +++ b/library/Graphite/Web/Widget/Graphs.php @@ -62,6 +62,15 @@ abstract class Graphs extends AbstractWidget */ protected $checkCommand; + /** + * The "real" check command (if any) of the monitored object we display graphs for + * + * E.g. the command executed remotely via check_by_ssh + * + * @var string|null + */ + protected $obscuredCheckCommand; + /** * Additional CSS classes for the
s around the images * @@ -83,7 +92,8 @@ abstract class Graphs extends AbstractWidget /** @var Host $object */ return new HostGraphs( $object->getName(), - $object->host_check_command + $object->host_check_command, + $object->_host_check_command ); case 'service': @@ -91,7 +101,8 @@ abstract class Graphs extends AbstractWidget return new ServiceGraphs( $object->getHost()->getName(), $object->getName(), - $object->service_check_command + $object->service_check_command, + $object->_service_check_command ); } } @@ -99,11 +110,14 @@ abstract class Graphs extends AbstractWidget /** * Constructor * - * @param string $checkCommand The check command of the monitored object we display graphs for + * @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 */ - public function __construct($checkCommand) + public function __construct($checkCommand, $obscuredCheckCommand) { $this->checkCommand = $checkCommand; + $this->obscuredCheckCommand = $obscuredCheckCommand; } /** @@ -135,6 +149,7 @@ abstract class Graphs extends AbstractWidget $filter = $this->getMonitoredObjectFilter(); $imageBaseUrl = $this->getImageBaseUrl(); $templates = static::getAllTemplates()->getTemplates(); + $checkCommand = $this->obscuredCheckCommand === null ? $this->checkCommand : $this->obscuredCheckCommand; $classes = $this->classes; $classes[] = 'images'; @@ -142,7 +157,7 @@ abstract class Graphs extends AbstractWidget foreach ($templates as $templateName => $template) { if ($this->designedForMyMonitoredObjectType($template) - && $template->getCheckCommand() === $this->checkCommand) { + && $template->getCheckCommand() === $checkCommand) { $charts = $template->getCharts(static::getMetricsDataSource(), $filter); if (! empty($charts)) { $result[] = $div; diff --git a/library/Graphite/Web/Widget/Graphs/Host.php b/library/Graphite/Web/Widget/Graphs/Host.php index ee9831c..b1dabcd 100644 --- a/library/Graphite/Web/Widget/Graphs/Host.php +++ b/library/Graphite/Web/Widget/Graphs/Host.php @@ -18,12 +18,14 @@ class Host extends Graphs /** * Constructor * - * @param string $host The host to render the graphs of - * @param string $checkCommand The check command of the monitored object we display graphs for + * @param string $host The host 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 */ - public function __construct($host, $checkCommand) + public function __construct($host, $checkCommand, $obscuredCheckCommand) { - parent::__construct($checkCommand); + parent::__construct($checkCommand, $obscuredCheckCommand); $this->host = $host; } diff --git a/library/Graphite/Web/Widget/Graphs/Service.php b/library/Graphite/Web/Widget/Graphs/Service.php index a74d1d6..ef07475 100644 --- a/library/Graphite/Web/Widget/Graphs/Service.php +++ b/library/Graphite/Web/Widget/Graphs/Service.php @@ -25,13 +25,15 @@ class Service extends Graphs /** * Constructor * - * @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 $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 */ - public function __construct($host, $service, $checkCommand) + public function __construct($host, $service, $checkCommand, $obscuredCheckCommand) { - parent::__construct($checkCommand); + parent::__construct($checkCommand, $obscuredCheckCommand); $this->host = $host; $this->service = $service;