Add preliminary subquery based comment and service problem fetch

The serviceproblems and host comment indicator are currently fetched
using subqueries (as this doesn't affect the group by).

refs 
This commit is contained in:
Jannis Moßhammer 2013-07-16 16:16:56 +02:00
parent c1860e7d5d
commit 2f79879a2e
3 changed files with 22 additions and 2 deletions
modules/monitoring
application/controllers
library/Monitoring
Backend/Ido/Query
View

@ -37,7 +37,7 @@ class Monitoring_ListController extends ModuleActionController
'host_handled',
'host_last_state_change',
'host_notifications_enabled',
'host_problems',
'host_unhandled_service_count',
'host_action_url',
'host_notes_url',
'host_last_comment'

@ -68,7 +68,7 @@ class StatusQuery extends AbstractQuery
'host_retry_check_interval' => 'hs.retry_check_interval',
'host_check_timeperiod_object_id' => 'hs.check_timeperiod_object_id',
'host_status_update_time' => 'hs.status_update_time',
'host_problems' => 'CASE WHEN hs.current_state = 0 THEN 0 ELSE 1 END',
'host_problem' => 'CASE WHEN hs.current_state = 0 THEN 0 ELSE 1 END',
'host_severity' => 'CASE WHEN hs.current_state = 0
THEN
CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL
@ -113,6 +113,7 @@ class StatusQuery extends AbstractQuery
'service_description' => 'so.name2 COLLATE latin1_general_ci',
'service_display_name' => 's.display_name',
'service_icon_image' => 's.icon_image',
),
'servicestatus' => array(
'current_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END',
@ -141,6 +142,9 @@ class StatusQuery extends AbstractQuery
'service_last_time_critical' => 'ss.last_time_critical',
'service_last_time_unknown' => 'ss.last_time_unknown',
),
'serviceproblemsummary' => array(
'host_unhandled_service_count' => 'sps.unhandled_service_count'
),
'lasthostcomment' => array(
'host_last_comment' => 'hlc.comment_id'
),
@ -315,6 +319,21 @@ class StatusQuery extends AbstractQuery
return $this;
}
protected function joinServiceproblemsummary()
{
$this->baseQuery->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.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'.
')')),
'sps.host_object_id = hs.host_object_id',
array()
);
}
protected function joinLasthostcomment()
{
$this->baseQuery->joinleft(

@ -37,6 +37,7 @@ class StatusView extends MonitoringView
'host_last_time_up',
'host_last_time_down',
'host_last_time_unreachable',
'host_unhandled_service_count',
// Services
'service',