From 43d8968bd2ccde47ca6dacd55695032519d4742b Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 May 2015 16:22:47 +0200 Subject: [PATCH 1/2] GroupsummaryQuery: add columns hosts_up_last_state_change hosts_pending_last_state_change hosts_down_last_state_change_handled hosts_unreachable_last_state_change_handled hosts_down_last_state_change_unhandled hosts_unreachable_last_state_change_unhandled refs #8860 --- .../Backend/Ido/Query/GroupsummaryQuery.php | 28 +++++++++++-------- .../Monitoring/DataView/Groupsummary.php | 6 ++++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 8b72bbf79..fd389562e 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -11,17 +11,23 @@ class GroupSummaryQuery extends IdoQuery protected $columnMap = array( 'hoststatussummary' => array( - 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', - 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', - 'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', - 'hosts_unreachable_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', - 'hosts_down' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 THEN 1 ELSE 0 END)', - 'hosts_down_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', - 'hosts_down_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', - 'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)', - 'hostgroup_name' => 'hostgroup_name', - 'hostgroup_alias' => 'hostgroup_alias', - 'hostgroup' => 'hostgroup' + 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', + 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', + 'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', + 'hosts_unreachable_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', + 'hosts_down' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 THEN 1 ELSE 0 END)', + 'hosts_down_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', + 'hosts_down_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', + 'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)', + 'hosts_up_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 0 THEN state_change ELSE 0 END)', + 'hosts_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 99 THEN state_change ELSE 0 END)', + 'hosts_down_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', + 'hosts_unreachable_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', + 'hosts_down_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', + 'hosts_unreachable_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', + 'hostgroup_name' => 'hostgroup_name', + 'hostgroup_alias' => 'hostgroup_alias', + 'hostgroup' => 'hostgroup' ), 'servicestatussummary' => array( 'services_total' => 'SUM(CASE WHEN object_type = \'service\' THEN 1 ELSE 0 END)', diff --git a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php index 562bed1da..d29c1c418 100644 --- a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php @@ -25,6 +25,12 @@ class Groupsummary extends DataView 'hosts_down_handled', 'hosts_down_unhandled', 'hosts_pending', + 'hosts_up_last_state_change', + 'hosts_pending_last_state_change', + 'hosts_down_last_state_change_handled', + 'hosts_unreachable_last_state_change_handled', + 'hosts_down_last_state_change_unhandled', + 'hosts_unreachable_last_state_change_unhandled', 'services_total', 'services_ok', 'services_unknown', From ab2f8e09d687dc105a979f5ac2113c43745f2054 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 May 2015 16:31:25 +0200 Subject: [PATCH 2/2] Calculate states for host group view from host states refs #8860 --- .../controllers/ListController.php | 6 ++ .../views/scripts/list/hostgroups.phtml | 90 ++++++++----------- 2 files changed, 44 insertions(+), 52 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 1261c7685..948050db6 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -528,6 +528,12 @@ class Monitoring_ListController extends Controller 'hosts_down_handled', 'hosts_down_unhandled', 'hosts_pending', + 'hosts_up_last_state_change', + 'hosts_pending_last_state_change', + 'hosts_down_last_state_change_handled', + 'hosts_unreachable_last_state_change_handled', + 'hosts_down_last_state_change_unhandled', + 'hosts_unreachable_last_state_change_unhandled', 'services_ok', 'services_unknown_handled', 'services_unknown_unhandled', diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index ef8cd78ea..90e96e660 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -1,4 +1,7 @@ -compact): ?> +compact): ?>
tabs; ?> sortBox; ?> @@ -15,7 +18,7 @@ if (count($hostgroups) === 0) { return; } ?> - +
@@ -23,57 +26,40 @@ if (count($hostgroups) === 0) { - - - services_critical_last_state_change_unhandled): ?> - + - services_unknown_last_state_change_unhandled): ?> - - services_warning_last_state_change_unhandled): ?> - - services_critical_last_state_change_handled): ?> - - services_unknown_last_state_change_handled): ?> - - services_warning_last_state_change_handled): ?> - - services_ok_last_state_change): ?> - - - - -
translate('Last Problem'); ?> translate('Host Group'); ?>translate('Service States'); ?>
- translate('CRITICAL'); ?> + hosts_down_unhandled) { + $handled = false; + $state = Host::STATE_DOWN; + $lastStateChange = $h->hosts_down_last_state_change_unhandled; + } elseif ($h->hosts_unreachable_unhandled) { + $handled = false; + $state = Host::STATE_UNREACHABLE; + $lastStateChange = $h->hosts_unreachable_last_state_change_unhandled; + } else { + $handled = true; + if ($h->hosts_down_handled) { + $state = Host::STATE_DOWN; + $lastStateChange = $h->hosts_down_last_state_change_handled; + } elseif ($h->hosts_unreachable_handled) { + $state = Host::STATE_UNREACHABLE; + $lastStateChange = $h->hosts_unreachable_last_state_change_handled; + } elseif ($h->hosts_up) { + $state = Host::STATE_UP; + $lastStateChange = $h->hosts_up_last_state_change; + } else { + $state = Host::STATE_PENDING; + $lastStateChange = $h->hosts_pending_last_state_change; + } + } + ?> +
+
- prefixedTimeSince($h->services_critical_last_state_change_unhandled); ?> + prefixedTimeSince($lastStateChange); ?>
- translate('UNKNOWN'); ?> -
- prefixedTimeSince($h->services_unknown_last_state_change_unhandled); ?> -
- translate('WARNING'); ?> -
- prefixedTimeSince($h->services_warning_last_state_change_unhandled); ?> -
- translate('CRITICAL'); ?> -
- prefixedTimeSince($h->services_critical_last_state_change_handled); ?> -
- translate('UNKNOWN'); ?> -
- prefixedTimeSince($h->services_unknown_last_state_change_handled); ?> -
- translate('WARNING'); ?> -
- prefixedTimeSince($h->services_warning_last_state_change_handled); ?> -
- translate('OK'); ?> -
- prefixedTimeSince($h->services_ok_last_state_change); ?> -
- translate('PENDING'); ?> -
- prefixedTimeSince($h->services_pending_last_state_change); ?> -
qlink( $h->hostgroup_alias, @@ -93,7 +79,7 @@ if (count($hostgroups) === 0) { )) ); ?> + services_ok): ?> qlink(