monitoring: Fix wrong unhandled service problems count in the hosts overview

The query was missing the is_active = 1 condition. I'll open an issue for the other
affected queries.

fixes #8013
This commit is contained in:
Eric Lippmann 2015-02-02 11:12:27 +01:00
parent d64ca3da99
commit f9047e85c5
1 changed files with 28 additions and 24 deletions

View File

@ -518,31 +518,35 @@ class StatusQuery extends IdoQuery
protected function joinServiceproblemsummary()
{
$sub = new Zend_Db_Expr('(SELECT'
. ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 0 ELSE 1 END) AS unhandled_services_count,'
. ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 1 ELSE 0 END) AS handled_services_count,'
. ' s.host_object_id FROM icinga_servicestatus ss'
. ' JOIN icinga_services s'
. ' ON s.service_object_id = ss.service_object_id'
. ' AND ss.current_state > 0'
. ' JOIN icinga_hoststatus hs'
. ' ON hs.host_object_id = s.host_object_id'
. ' GROUP BY s.host_object_id)');
$select = <<<'SQL'
SELECT
SUM(
CASE WHEN(ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0
THEN 0
ELSE 1
END
) AS unhandled_services_count,
SUM(
CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0) ) > 0
THEN 1
ELSE 0
END
) AS handled_services_count,
s.host_object_id
FROM
icinga_servicestatus ss
JOIN icinga_objects o ON o.object_id = ss.service_object_id
JOIN icinga_services s ON s.service_object_id = o.object_id
JOIN icinga_hoststatus hs ON hs.host_object_id = s.host_object_id
WHERE
o.is_active = 1
AND o.objecttype_id = 2
AND ss.current_state > 0
GROUP BY
s.host_object_id
SQL;
$this->select->joinLeft(
array('sps' => $sub),
'sps.host_object_id = hs.host_object_id',
array()
);
return;
$this->select->joinleft(
array ('sps' => new \Zend_Db_Expr(
'(SELECT COUNT(s.service_object_id) as unhandled_service_count, s.host_object_id as host_object_id '.
'FROM icinga_services s INNER JOIN icinga_servicestatus ss ON ss.current_state != 0 AND '.
'ss.problem_has_been_acknowledged = 0 AND ss.scheduled_downtime_depth = 0 AND '.
'ss.service_object_id = s.service_object_id '.
'GROUP BY s.host_object_id'.
')')),
array('sps' => new Zend_Db_Expr('(' . $select . ')')),
'sps.host_object_id = hs.host_object_id',
array()
);