From e947b4363bf4c996a1c6c702357e0871844b0573 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sun, 9 Mar 2014 16:37:47 +0100 Subject: [PATCH] System->Performance: Add RuntimeVariables view helper for 'average_{,scheduled_}services_per_host' calculation. --- .../controllers/ProcessController.php | 2 +- .../views/helpers/RuntimeVariables.php | 66 +++++++++++++++++++ .../views/scripts/process/performance.phtml | 4 +- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 modules/monitoring/application/views/helpers/RuntimeVariables.php diff --git a/modules/monitoring/application/controllers/ProcessController.php b/modules/monitoring/application/controllers/ProcessController.php index 758d5b745..1152df09d 100644 --- a/modules/monitoring/application/controllers/ProcessController.php +++ b/modules/monitoring/application/controllers/ProcessController.php @@ -75,4 +75,4 @@ class Monitoring_ProcessController extends MonitoringController } } -// @codingStandardsIgnoreStop \ No newline at end of file +// @codingStandardsIgnoreStop diff --git a/modules/monitoring/application/views/helpers/RuntimeVariables.php b/modules/monitoring/application/views/helpers/RuntimeVariables.php new file mode 100644 index 000000000..28b143525 --- /dev/null +++ b/modules/monitoring/application/views/helpers/RuntimeVariables.php @@ -0,0 +1,66 @@ + + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + * + */ +// {{{ICINGA_LICENSE_HEADER}}} + +/** + * Convert runtime summary data into a simple usable stdClass + */ +class Zend_View_Helper_RuntimeVariables extends Zend_View_Helper_Abstract +{ + /** + * Create dispatch instance + * + * @return self + */ + public function runtimeVariables() + { + return $this; + } + + /** + * Create a condensed row of object data + * + * @param $result stdClass + * + * @return stdClass Condensed row + */ + public function create(stdClass $result) + { + $out = new stdClass(); + $out->total_hosts = $result->total_hosts; + $out->total_scheduled_hosts = $result->total_scheduled_hosts; + $out->total_services = $result->total_services; + $out->total_scheduled_services = $result->total_scheduled_services; + $out->average_services_per_host = $result->total_services / $result->total_hosts; + $out->average_scheduled_services_per_host = $result->total_scheduled_services / $result->total_scheduled_hosts; + + return $out; + } +} +// @codingStandardsIgnoreStop diff --git a/modules/monitoring/application/views/scripts/process/performance.phtml b/modules/monitoring/application/views/scripts/process/performance.phtml index 962b56407..54cbf5a2b 100644 --- a/modules/monitoring/application/views/scripts/process/performance.phtml +++ b/modules/monitoring/application/views/scripts/process/performance.phtml @@ -1,5 +1,5 @@ runtimevariables; + $rv = $this->runtimeVariables()->create($this->runtimevariables); $ps = $this->programstatus; $cp = $this->checkPerformance()->create($this->checkperformance); /** @var Zend_View_Helper_CommandForm $ch */ @@ -382,4 +382,4 @@ - \ No newline at end of file +