diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatehistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatehistoryQuery.php index 40e8a3fab..168a9c87c 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatehistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatehistoryQuery.php @@ -13,6 +13,16 @@ class ServicestatehistoryQuery extends IdoQuery */ protected $allowCustomVars = true; + /** + * {@inheritdoc} + */ + protected $groupBase = array('statehistory', array('sh.statehistory_id', 'so.object_id')); + + /** + * {@inheritdoc} + */ + protected $groupOrigin = array('hostgroups', 'servicegroups'); + /** * Array to map type names to type ids for query optimization * @@ -30,22 +40,6 @@ class ServicestatehistoryQuery extends IdoQuery 'instances' => array( 'instance_name' => 'i.instance_name' ), - 'statehistory' => array( - 'host' => 'so.name1 COLLATE latin1_general_ci', - 'host_name' => 'so.name1', - 'object_type' => '(\'service\')', - 'service' => 'so.name2 COLLATE latin1_general_ci', - 'service_description' => 'so.name2', - 'service_host' => 'so.name1 COLLATE latin1_general_ci', - 'service_host_name' => 'so.name1' - ), - 'history' => array( - 'type' => "(CASE WHEN sh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)", - 'timestamp' => 'UNIX_TIMESTAMP(sh.state_time)', - 'object_id' => 'sh.object_id', - 'state' => 'sh.state', - 'output' => "('[ ' || sh.current_check_attempt || '/' || sh.max_check_attempts || ' ] ' || sh.output)", - ), 'hostgroups' => array( 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', 'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci', @@ -62,7 +56,21 @@ class ServicestatehistoryQuery extends IdoQuery ), 'services' => array( 'service_display_name' => 's.display_name COLLATE latin1_general_ci' - ) + ), + 'statehistory' => array( + 'host' => 'so.name1 COLLATE latin1_general_ci', + 'host_name' => 'so.name1', + 'object_id' => 'sh.object_id', + 'object_type' => '(\'service\')', + 'output' => "('[ ' || sh.current_check_attempt || '/' || sh.max_check_attempts || ' ] ' || sh.output)", + 'service' => 'so.name2 COLLATE latin1_general_ci', + 'service_description' => 'so.name2', + 'service_host' => 'so.name1 COLLATE latin1_general_ci', + 'service_host_name' => 'so.name1', + 'state' => 'sh.state', + 'timestamp' => 'UNIX_TIMESTAMP(sh.state_time)', + 'type' => "(CASE WHEN sh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)" + ), ); /** @@ -97,7 +105,6 @@ class ServicestatehistoryQuery extends IdoQuery array() ); $this->joinedVirtualTables['statehistory'] = true; - $this->joinedVirtualTables['history'] = true; } /** @@ -177,21 +184,4 @@ class ServicestatehistoryQuery extends IdoQuery array() ); } - - /** - * {@inheritdoc} - */ - public function getGroup() - { - $group = array(); - if ($this->hasJoinedVirtualTable('hostgroups') || $this->hasJoinedVirtualTable('servicegroups')) { - $group = array('sh.statehistory_id', 'so.object_id'); - if ($this->hasJoinedVirtualTable('services')) { - $group[] = 'h.host_id'; - $group[] = 's.service_id'; - } - } - - return $group; - } }