From c5bed8ad00925b3904a51439d92949f84e60ec0f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 22 Oct 2013 14:27:19 +0200 Subject: [PATCH] Monitoring: Add host and service unhandled column; remove s from host- and servicegroups --- .../views/scripts/show/components/hostgroups.phtml | 4 ++-- .../scripts/show/components/servicegroups.phtml | 2 +- .../Monitoring/Backend/Ido/Query/StatusQuery.php | 12 +++++++----- .../Backend/Statusdat/Query/StatusQuery.php | 13 ++++++++++++- .../library/Monitoring/DataView/HostStatus.php | 3 ++- .../library/Monitoring/DataView/ServiceStatus.php | 3 ++- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml index ffc8c501f..8f7709ef0 100644 --- a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml @@ -1,7 +1,7 @@ hostgroups as $name => $alias) { - $hostgroups[] = '' + $hostgroups[] = '' . $alias . ''; } @@ -22,4 +22,4 @@ foreach ($object->hostgroups as $name => $alias) { - \ No newline at end of file + diff --git a/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml b/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml index 5f79db497..512ad1130 100644 --- a/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml +++ b/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml @@ -1,7 +1,7 @@ servicegroups as $name => $alias) { - $servicegroups[] = '' + $servicegroups[] = '' . $alias . ''; } diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index d7c79730c..ac6bfd811 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -30,6 +30,7 @@ class StatusQuery extends IdoQuery 'host_acknowledged' => 'hs.problem_has_been_acknowledged', 'host_in_downtime' => 'CASE WHEN (hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END', 'host_handled' => 'CASE WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0 THEN 1 ELSE 0 END', + 'host_unhandled' => 'CASE WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) = 0 THEN 1 ELSE 0 END', 'host_last_state_change' => 'UNIX_TIMESTAMP(hs.last_state_change)', 'host_last_hard_state' => 'hs.last_hard_state', 'host_last_hard_state_change' => 'UNIX_TIMESTAMP(hs.last_hard_state_change)', @@ -127,13 +128,13 @@ class StatusQuery extends IdoQuery ELSE 4 END END - END', + END' ), 'hostgroups' => array( - 'hostgroups' => 'hgo.name1', + 'hostgroup' => 'hgo.name1', ), 'servicegroups' => array( - 'servicegroups' => 'sgo.name1', + 'servicegroup' => 'sgo.name1', ), 'services' => array( 'service_host_name' => 'so.name1 COLLATE latin1_general_ci', @@ -142,8 +143,8 @@ class StatusQuery extends IdoQuery 'service_display_name' => 's.display_name', 'service_icon_image' => 's.icon_image', 'service_action_url' => 's.action_url', - 'service_notes_url' => 's.notes_url' - + 'service_notes_url' => 's.notes_url', + 'object_type' => '(\'service\')' ), 'servicestatus' => array( 'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END', @@ -155,6 +156,7 @@ class StatusQuery extends IdoQuery 'service_acknowledged' => 'ss.problem_has_been_acknowledged', 'service_in_downtime' => 'CASE WHEN (ss.scheduled_downtime_depth = 0 OR ss.scheduled_downtime_depth IS NULL) THEN 0 ELSE 1 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_unhandled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) = 0 THEN 1 ELSE 0 END', 'service_last_state_change' => 'UNIX_TIMESTAMP(ss.last_state_change)', 'service_check_command' => 'ss.check_command', 'service_last_time_ok' => 'ss.last_time_ok', diff --git a/modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusQuery.php index e1141c7fa..dba4e311d 100644 --- a/modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusQuery.php @@ -142,6 +142,7 @@ class StatusQuery extends StatusdatQuery 'host_state' => 'getStateForHost', 'host_hard_state' => 'getHardStateForHost', 'host_handled' => 'isHandledForHost', + 'host_unhandled' => 'isHostUnhandled', 'host_severity' => 'getSeverityForHost', 'host_in_downtime' => 'isInDowntimeForHost', 'host_problem' => 'isProblemForHost', @@ -149,6 +150,7 @@ class StatusQuery extends StatusdatQuery 'service_state' => 'getState', 'service_hard_state' => 'getHardState', 'service_handled' => 'isHandled', + 'service_unhandled' => 'isUnhandled', 'service_severity' => 'getSeverity', 'service_in_downtime' => 'isInDowntime', 'service_problem' => 'isProblem', @@ -253,12 +255,16 @@ class StatusQuery extends StatusdatQuery public function isHandled(&$host) { - return $host->status->current_state == 0 || $host->status->problem_has_been_acknowledged || $host->status->scheduled_downtime_depth; } + public function isUnhandled(&$hostOrService) + { + return !$this->isHandled($hostOrService); + } + public function getNrOfUnhandledServices(&$obj) { $host = &$obj->host; @@ -329,6 +335,11 @@ class StatusQuery extends StatusdatQuery return $this->isHandled($obj->host); } + public function isHostUnhandled(&$obj) + { + return $this->isUnhandled($obj->host); + } + public function getSeverityForHost(&$obj) { return $this->getSeverity($obj->host); diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index 2bb70c9e8..ec2c26002 100644 --- a/modules/monitoring/library/Monitoring/DataView/HostStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/HostStatus.php @@ -23,6 +23,7 @@ class HostStatus extends DataView 'host_state', 'host_state_type', 'host_handled', + 'host_unhandled', 'host_in_downtime', 'host_acknowledged', 'host_last_state_change', @@ -105,7 +106,7 @@ class HostStatus extends DataView public function getFilterColumns() { - return array('hostgroups', 'servicegroups', 'service_problem'); + return array('hostgroup', 'servicegroup', 'service_problems'); } public function isValidFilterTarget($column) diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index 8a008b2c1..fe1ce858e 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -26,6 +26,7 @@ class ServiceStatus extends DataView 'service_in_downtime', 'service_acknowledged', 'service_handled', + 'service_unhandled', 'service_output', 'service_last_state_change', 'service_icon_image', @@ -131,7 +132,7 @@ class ServiceStatus extends DataView public function getFilterColumns() { - return array('hostgroups', 'servicegroups', 'service_problem'); + return array('hostgroup', 'servicegroup', 'service_problems'); } public function isValidFilterTarget($column)