monitoring: Fix service status query regarding handled/unhandled and using distinct

refs #9009
This commit is contained in:
Eric Lippmann 2015-06-05 11:49:00 +02:00
parent c08a98f6ac
commit 55921b4854
1 changed files with 9 additions and 7 deletions

View File

@ -146,12 +146,12 @@ class ServicestatusQuery extends IdoQuery
'servicegroup_alias' => 'sg.alias COLLATE latin1_general_ci' 'servicegroup_alias' => 'sg.alias COLLATE latin1_general_ci'
), ),
'servicestatus' => array( 'servicestatus' => array(
'service_handled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth) > 0 THEN 1 ELSE 0 END', 'service_handled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 1 ELSE 0 END',
'service_hard_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE CASE WHEN ss.state_type = 1 THEN ss.current_state ELSE ss.last_hard_state END END', 'service_hard_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE CASE WHEN ss.state_type = 1 THEN ss.current_state ELSE ss.last_hard_state END END',
'service_last_hard_state_change' => 'UNIX_TIMESTAMP(ss.last_hard_state_change)', 'service_last_hard_state_change' => 'UNIX_TIMESTAMP(ss.last_hard_state_change)',
'service_last_state_change' => 'UNIX_TIMESTAMP(ss.last_state_change)', 'service_last_state_change' => 'UNIX_TIMESTAMP(ss.last_state_change)',
'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END', 'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END',
'service_unhandled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth) = 0 THEN 1 ELSE 0 END' 'service_unhandled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) = 0 THEN 1 ELSE 0 END',
) )
); );
@ -201,6 +201,7 @@ class ServicestatusQuery extends IdoQuery
'hgo.objecttype_id = ?', 'hgo.objecttype_id = ?',
3 3
); );
$this->group(array('so.name2', 'so.name1'));
} }
/** /**
@ -252,7 +253,7 @@ class ServicestatusQuery extends IdoQuery
'sgo.objecttype_id = ?', 'sgo.objecttype_id = ?',
4 4
); );
$this->distinct(); $this->group(array('so.name2', 'so.name1'));
} }
/** /**
@ -260,6 +261,7 @@ class ServicestatusQuery extends IdoQuery
*/ */
protected function joinServicestatus() protected function joinServicestatus()
{ {
$this->requireVirtualTable('hoststatus');
$this->select->join( $this->select->join(
array('ss' => $this->prefix . 'servicestatus'), array('ss' => $this->prefix . 'servicestatus'),
'ss.service_object_id = so.object_id', 'ss.service_object_id = so.object_id',