From a4fdb30067ef8e6d3084018d360ab673a6fc244e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 7 Aug 2015 15:37:35 +0200 Subject: [PATCH] Host Overview: Use a dedicated query to fetch service summaries refs #9864 --- .../application/controllers/ListController.php | 15 +++++++++++++++ .../application/views/scripts/list/hosts.phtml | 10 +++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 9a7199580..a06a09d8c 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -120,6 +120,21 @@ class Monitoring_ListController extends Controller 'host_address' => $this->translate('Address'), 'host_last_check' => $this->translate('Last Check') ), $query); + + $summary = $this->backend->select()->from('Hostservicestatussummary', array( + 'host_name', + 'unhandled_service_count' + )); + $summary->addFilter($query->getFilter()); + $this->setupSortControl(array( + 'host_severity' => $this->translate('Severity'), + 'host_state' => $this->translate('Current State'), + 'host_display_name' => $this->translate('Hostname'), + 'host_address' => $this->translate('Address'), + 'host_last_check' => $this->translate('Last Check') + ), $summary); + $summary->limit($query->getLimit(), $query->getOffset()); + $this->view->summary = $summary->fetchPairs(); } /** diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 8938d5703..62ca65121 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -58,11 +58,11 @@ if (! $this->compact): ?> 'class' => 'rowaction' ) ); ?> - host_unhandled_services) && $host->host_unhandled_services > 0): ?> + host_name])): ?> (qlink( sprintf( - $this->translatePlural('%u unhandled service', '%u unhandled services', $host->host_unhandled_services), - $host->host_unhandled_services + $this->translatePlural('%u unhandled service', '%u unhandled services', $summary[$host->host_name]), + $summary[$host->host_name] ), 'monitoring/list/services', array( @@ -76,9 +76,9 @@ if (! $this->compact): ?> $this->translatePlural( 'List %s unhandled service problem on host %s', 'List %s unhandled service problems on host %s', - $host->host_unhandled_services + $summary[$host->host_name] ), - $host->host_unhandled_services, + $summary[$host->host_name], $host->host_name ) )