Merge pull request #3404 from Icinga/bugfix/hosts-services-severity-3395
Make host and service groups sortable by the members' severities
This commit is contained in:
commit
20891b8127
|
@ -485,6 +485,7 @@ class ListController extends Controller
|
|||
$this->setupPaginationControl($serviceGroups);
|
||||
$this->setupSortControl(array(
|
||||
'servicegroup_alias' => $this->translate('Service Group Name'),
|
||||
'services_severity' => $this->translate('Severity'),
|
||||
'services_total' => $this->translate('Total Services')
|
||||
), $serviceGroups);
|
||||
$this->filterQuery($serviceGroups);
|
||||
|
@ -531,6 +532,7 @@ class ListController extends Controller
|
|||
$this->setupPaginationControl($hostGroups);
|
||||
$this->setupSortControl(array(
|
||||
'hostgroup_alias' => $this->translate('Host Group Name'),
|
||||
'hosts_severity' => $this->translate('Severity'),
|
||||
'hosts_total' => $this->translate('Total Hosts'),
|
||||
'services_total' => $this->translate('Total Services')
|
||||
), $hostGroups);
|
||||
|
|
|
@ -26,6 +26,28 @@ class HostgroupQuery extends IdoQuery
|
|||
),
|
||||
'hoststatus' => array(
|
||||
'host_handled' => 'CASE WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0 THEN 1 ELSE 0 END',
|
||||
'host_severity' => '
|
||||
CASE
|
||||
WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL
|
||||
THEN 16
|
||||
ELSE
|
||||
CASE
|
||||
WHEN hs.current_state = 0
|
||||
THEN 1
|
||||
ELSE
|
||||
CASE
|
||||
WHEN hs.current_state = 1 THEN 64
|
||||
WHEN hs.current_state = 2 THEN 32
|
||||
ELSE 256
|
||||
END
|
||||
+
|
||||
CASE
|
||||
WHEN hs.problem_has_been_acknowledged = 1 THEN 2
|
||||
WHEN hs.scheduled_downtime_depth > 0 THEN 1
|
||||
ELSE 256
|
||||
END
|
||||
END
|
||||
END',
|
||||
'host_state' => 'CASE WHEN hs.has_been_checked = 0 OR (hs.has_been_checked IS NULL AND hs.hoststatus_id IS NOT NULL) THEN 99 ELSE hs.current_state END'
|
||||
),
|
||||
'instances' => array(
|
||||
|
@ -42,6 +64,43 @@ class HostgroupQuery extends IdoQuery
|
|||
),
|
||||
'servicestatus' => array(
|
||||
'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_severity' => '
|
||||
CASE WHEN ss.current_state = 0
|
||||
THEN
|
||||
CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL
|
||||
THEN 16
|
||||
ELSE 0
|
||||
END
|
||||
+
|
||||
CASE WHEN ss.problem_has_been_acknowledged = 1
|
||||
THEN 2
|
||||
ELSE
|
||||
CASE WHEN ss.scheduled_downtime_depth > 0
|
||||
THEN 1
|
||||
ELSE 4
|
||||
END
|
||||
END
|
||||
ELSE
|
||||
CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 16
|
||||
WHEN ss.current_state = 1 THEN 32
|
||||
WHEN ss.current_state = 2 THEN 128
|
||||
WHEN ss.current_state = 3 THEN 64
|
||||
ELSE 256
|
||||
END
|
||||
+
|
||||
CASE WHEN hs.current_state > 0
|
||||
THEN 1024
|
||||
ELSE
|
||||
CASE WHEN ss.problem_has_been_acknowledged = 1
|
||||
THEN 512
|
||||
ELSE
|
||||
CASE WHEN ss.scheduled_downtime_depth > 0
|
||||
THEN 256
|
||||
ELSE 2048
|
||||
END
|
||||
END
|
||||
END
|
||||
END',
|
||||
'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR (ss.has_been_checked IS NULL AND ss.servicestatus_id IS NOT NULL) THEN 99 ELSE ss.current_state END'
|
||||
)
|
||||
);
|
||||
|
|
|
@ -23,6 +23,7 @@ class HostgroupsummaryQuery extends IdoQuery
|
|||
'hosts_down_handled' => 'SUM(CASE WHEN host_state = 1 AND host_handled = 1 THEN 1 ELSE 0 END)',
|
||||
'hosts_down_unhandled' => 'SUM(CASE WHEN host_state = 1 AND host_handled = 0 THEN 1 ELSE 0 END)',
|
||||
'hosts_pending' => 'SUM(CASE WHEN host_state = 99 THEN 1 ELSE 0 END)',
|
||||
'hosts_severity' => 'MAX(host_severity)',
|
||||
'hosts_total' => 'SUM(CASE WHEN host_state IS NOT NULL THEN 1 ELSE 0 END)',
|
||||
'hosts_unreachable' => 'SUM(CASE WHEN host_state = 2 THEN 1 ELSE 0 END)',
|
||||
'hosts_unreachable_handled' => 'SUM(CASE WHEN host_state = 2 AND host_handled = 1 THEN 1 ELSE 0 END)',
|
||||
|
@ -85,8 +86,10 @@ class HostgroupsummaryQuery extends IdoQuery
|
|||
'hostgroup_alias',
|
||||
'hostgroup_name',
|
||||
'host_handled',
|
||||
'host_severity',
|
||||
'host_state',
|
||||
'service_handled' => new Zend_Db_Expr('NULL'),
|
||||
'service_severity' => new Zend_Db_Expr('0'),
|
||||
'service_state' => new Zend_Db_Expr('NULL'),
|
||||
)
|
||||
);
|
||||
|
@ -97,8 +100,10 @@ class HostgroupsummaryQuery extends IdoQuery
|
|||
'hostgroup_alias',
|
||||
'hostgroup_name',
|
||||
'host_handled' => new Zend_Db_Expr('NULL'),
|
||||
'host_severity' => new Zend_Db_Expr('0'),
|
||||
'host_state' => new Zend_Db_Expr('NULL'),
|
||||
'service_handled',
|
||||
'service_severity',
|
||||
'service_state'
|
||||
)
|
||||
);
|
||||
|
|
|
@ -35,6 +35,43 @@ class ServicegroupQuery extends IdoQuery
|
|||
),
|
||||
'servicestatus' => array(
|
||||
'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_severity' => '
|
||||
CASE WHEN ss.current_state = 0
|
||||
THEN
|
||||
CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL
|
||||
THEN 16
|
||||
ELSE 0
|
||||
END
|
||||
+
|
||||
CASE WHEN ss.problem_has_been_acknowledged = 1
|
||||
THEN 2
|
||||
ELSE
|
||||
CASE WHEN ss.scheduled_downtime_depth > 0
|
||||
THEN 1
|
||||
ELSE 4
|
||||
END
|
||||
END
|
||||
ELSE
|
||||
CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 16
|
||||
WHEN ss.current_state = 1 THEN 32
|
||||
WHEN ss.current_state = 2 THEN 128
|
||||
WHEN ss.current_state = 3 THEN 64
|
||||
ELSE 256
|
||||
END
|
||||
+
|
||||
CASE WHEN hs.current_state > 0
|
||||
THEN 1024
|
||||
ELSE
|
||||
CASE WHEN ss.problem_has_been_acknowledged = 1
|
||||
THEN 512
|
||||
ELSE
|
||||
CASE WHEN ss.scheduled_downtime_depth > 0
|
||||
THEN 256
|
||||
ELSE 2048
|
||||
END
|
||||
END
|
||||
END
|
||||
END',
|
||||
'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR (ss.has_been_checked IS NULL AND ss.servicestatus_id IS NOT NULL) THEN 99 ELSE ss.current_state END'
|
||||
)
|
||||
);
|
||||
|
|
|
@ -22,6 +22,7 @@ class ServicegroupsummaryQuery extends IdoQuery
|
|||
'services_critical_unhandled' => 'SUM(CASE WHEN service_state = 2 AND service_handled = 0 THEN 1 ELSE 0 END)',
|
||||
'services_ok' => 'SUM(CASE WHEN service_state = 0 THEN 1 ELSE 0 END)',
|
||||
'services_pending' => 'SUM(CASE WHEN service_state = 99 THEN 1 ELSE 0 END)',
|
||||
'services_severity' => 'MAX(service_severity)',
|
||||
'services_total' => 'SUM(CASE WHEN service_state IS NOT NULL THEN 1 ELSE 0 END)',
|
||||
'services_unknown' => 'SUM(CASE WHEN service_state = 3 THEN 1 ELSE 0 END)',
|
||||
'services_unknown_handled' => 'SUM(CASE WHEN service_state = 3 AND service_handled = 1 THEN 1 ELSE 0 END)',
|
||||
|
@ -65,6 +66,7 @@ class ServicegroupsummaryQuery extends IdoQuery
|
|||
'servicegroup_alias',
|
||||
'servicegroup_name',
|
||||
'service_handled',
|
||||
'service_severity',
|
||||
'service_state'
|
||||
)
|
||||
);
|
||||
|
|
|
@ -16,6 +16,7 @@ class Hostgroupsummary extends DataView
|
|||
'hosts_down_handled',
|
||||
'hosts_down_unhandled',
|
||||
'hosts_pending',
|
||||
'hosts_severity',
|
||||
'hosts_total',
|
||||
'hosts_unreachable_handled',
|
||||
'hosts_unreachable_unhandled',
|
||||
|
@ -42,6 +43,13 @@ class Hostgroupsummary extends DataView
|
|||
return array(
|
||||
'hostgroup_alias' => array(
|
||||
'order' => self::SORT_ASC
|
||||
),
|
||||
'hosts_severity' => array(
|
||||
'columns' => array(
|
||||
'hosts_severity',
|
||||
'hostgroup_alias ASC'
|
||||
),
|
||||
'order' => self::SORT_DESC
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ class Servicegroupsummary extends DataView
|
|||
'services_critical_unhandled',
|
||||
'services_ok',
|
||||
'services_pending',
|
||||
'services_severity',
|
||||
'services_total',
|
||||
'services_unknown_handled',
|
||||
'services_unknown_unhandled',
|
||||
|
@ -35,6 +36,13 @@ class Servicegroupsummary extends DataView
|
|||
return array(
|
||||
'servicegroup_alias' => array(
|
||||
'order' => self::SORT_ASC
|
||||
),
|
||||
'services_severity' => array(
|
||||
'columns' => array(
|
||||
'services_severity',
|
||||
'servicegroup_alias ASC'
|
||||
),
|
||||
'order' => self::SORT_DESC
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue