From 1ea7335b96b9b220b922e0e696856e5f02a3e1f7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 5 Jun 2015 09:15:09 +0200 Subject: [PATCH] monitoring: Support filtering the service group summary by service custom variables refs #9009 --- .../Ido/Query/ServicestatussummaryQuery.php | 54 ++++++------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatussummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatussummaryQuery.php index 0a04e9c41..306e52843 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatussummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatussummaryQuery.php @@ -24,24 +24,20 @@ class ServicestatussummaryQuery extends IdoQuery 'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci', 'hostgroup_name' => 'hgo.name1' ), - 'hosts' => array( - 'host' => 'so.name1 COLLATE latin1_general_ci', - 'host_alias' => 'h.alias COLLATE latin1_general_ci', - 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', - 'host_name' => 'so.name1' - ), 'servicegroups' => array( 'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci', 'servicegroup_name' => 'sgo.name1', 'servicegroup_alias' => 'sg.alias COLLATE latin1_general_ci' ), - 'services' => array( - 'service_display_name' => 's.display_name COLLATE latin1_general_ci' - ), 'servicestatussummary' => array( + 'host' => 'so.name1 COLLATE latin1_general_ci', + 'host_alias' => 'h.alias COLLATE latin1_general_ci', + 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', + 'host_name' => 'so.name1', 'object_type' => '(\'service\')', 'service' => 'so.name2 COLLATE latin1_general_ci', 'service_description' => 'so.name2', + 'service_display_name' => 's.display_name COLLATE latin1_general_ci', 'service_host' => 'so.name1 COLLATE latin1_general_ci', 'service_host_name' => 'so.name1', 'services_critical' => 'SUM(CASE WHEN ss.has_been_checked != 1 THEN 0 ELSE CASE WHEN ss.current_state = 2 THEN 1 ELSE 0 END END)', @@ -75,10 +71,18 @@ class ServicestatussummaryQuery extends IdoQuery $this->select->from( array('so' => $this->prefix . 'objects'), array() + )->join( + array('s' => $this->prefix . 'services'), + 's.service_object_id = so.object_id', + array() )->join( array('ss' => $this->prefix . 'servicestatus'), 'ss.service_object_id = so.object_id', array() + )->join( + array('h' => $this->prefix . 'hosts'), + 'h.host_object_id = s.host_object_id', + array() )->where( 'so.is_active = ?', 1 @@ -87,6 +91,8 @@ class ServicestatussummaryQuery extends IdoQuery 2 ); $this->joinedVirtualTables['servicestatussummary'] = true; + // Provide table services for custom var joins + $this->joinedVirtualTables['services'] = true; } /** @@ -94,7 +100,6 @@ class ServicestatussummaryQuery extends IdoQuery */ protected function joinHostgroups() { - $this->requireVirtualTable('services'); $this->select->join( array('hgm' => $this->prefix . 'hostgroup_members'), 'hgm.host_object_id = s.host_object_id', @@ -116,20 +121,6 @@ class ServicestatussummaryQuery extends IdoQuery ); } - /** - * Join hosts - */ - protected function joinHosts() - { - $this->requireVirtualTable('services'); - $this->select->join( - array('h' => $this->prefix . 'hosts'), - 'h.host_object_id = s.host_object_id', - array() - ); - // TODO(el): Join host objects for is_active check? - } - /** * Join host status */ @@ -138,10 +129,9 @@ class ServicestatussummaryQuery extends IdoQuery $this->requireVirtualTable('services'); $this->select->join( array('hs' => $this->prefix . 'hoststatus'), - 'hs.host_object_id = s.host_object_id', + 'hs.host_object_id = so.object_id', array() ); - // TODO(el): Join host objects for is_active check? } /** @@ -171,16 +161,4 @@ class ServicestatussummaryQuery extends IdoQuery ) ->group('sgo.name1'); } - - /** - * Join services - */ - protected function joinServices() - { - $this->select->join( - array('s' => $this->prefix . 'services'), - 's.service_object_id = so.object_id', - array() - ); - } }