Monitoring: Add host and service unhandled column; remove s from host- and servicegroups

This commit is contained in:
Eric Lippmann 2013-10-22 14:27:19 +02:00
parent 30b37aa1e5
commit c5bed8ad00
6 changed files with 26 additions and 11 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
$hostgroups = array(); $hostgroups = array();
foreach ($object->hostgroups as $name => $alias) { foreach ($object->hostgroups as $name => $alias) {
$hostgroups[] = '<a href="' . $this->href('monitoring/list/hosts', array('hostgroups' => $name)) . '">' $hostgroups[] = '<a href="' . $this->href('monitoring/list/hosts', array('hostgroup' => $name)) . '">'
. $alias . $alias
. '</a>'; . '</a>';
} }

View File

@ -1,7 +1,7 @@
<?php <?php
$servicegroups = array(); $servicegroups = array();
foreach ($object->servicegroups as $name => $alias) { foreach ($object->servicegroups as $name => $alias) {
$servicegroups[] = '<a href="' . $this->href('monitoring/list/service', array('servicegroups' => $name)) . '">' $servicegroups[] = '<a href="' . $this->href('monitoring/list/service', array('servicegroup' => $name)) . '">'
. $alias . $alias
. '</a>'; . '</a>';
} }

View File

@ -30,6 +30,7 @@ class StatusQuery extends IdoQuery
'host_acknowledged' => 'hs.problem_has_been_acknowledged', 'host_acknowledged' => 'hs.problem_has_been_acknowledged',
'host_in_downtime' => 'CASE WHEN (hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END', '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_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_state_change' => 'UNIX_TIMESTAMP(hs.last_state_change)',
'host_last_hard_state' => 'hs.last_hard_state', 'host_last_hard_state' => 'hs.last_hard_state',
'host_last_hard_state_change' => 'UNIX_TIMESTAMP(hs.last_hard_state_change)', 'host_last_hard_state_change' => 'UNIX_TIMESTAMP(hs.last_hard_state_change)',
@ -127,13 +128,13 @@ class StatusQuery extends IdoQuery
ELSE 4 ELSE 4
END END
END END
END', END'
), ),
'hostgroups' => array( 'hostgroups' => array(
'hostgroups' => 'hgo.name1', 'hostgroup' => 'hgo.name1',
), ),
'servicegroups' => array( 'servicegroups' => array(
'servicegroups' => 'sgo.name1', 'servicegroup' => 'sgo.name1',
), ),
'services' => array( 'services' => array(
'service_host_name' => 'so.name1 COLLATE latin1_general_ci', 'service_host_name' => 'so.name1 COLLATE latin1_general_ci',
@ -142,8 +143,8 @@ class StatusQuery extends IdoQuery
'service_display_name' => 's.display_name', 'service_display_name' => 's.display_name',
'service_icon_image' => 's.icon_image', 'service_icon_image' => 's.icon_image',
'service_action_url' => 's.action_url', 'service_action_url' => 's.action_url',
'service_notes_url' => 's.notes_url' 'service_notes_url' => 's.notes_url',
'object_type' => '(\'service\')'
), ),
'servicestatus' => array( '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', '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_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_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_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_last_state_change' => 'UNIX_TIMESTAMP(ss.last_state_change)',
'service_check_command' => 'ss.check_command', 'service_check_command' => 'ss.check_command',
'service_last_time_ok' => 'ss.last_time_ok', 'service_last_time_ok' => 'ss.last_time_ok',

View File

@ -142,6 +142,7 @@ class StatusQuery extends StatusdatQuery
'host_state' => 'getStateForHost', 'host_state' => 'getStateForHost',
'host_hard_state' => 'getHardStateForHost', 'host_hard_state' => 'getHardStateForHost',
'host_handled' => 'isHandledForHost', 'host_handled' => 'isHandledForHost',
'host_unhandled' => 'isHostUnhandled',
'host_severity' => 'getSeverityForHost', 'host_severity' => 'getSeverityForHost',
'host_in_downtime' => 'isInDowntimeForHost', 'host_in_downtime' => 'isInDowntimeForHost',
'host_problem' => 'isProblemForHost', 'host_problem' => 'isProblemForHost',
@ -149,6 +150,7 @@ class StatusQuery extends StatusdatQuery
'service_state' => 'getState', 'service_state' => 'getState',
'service_hard_state' => 'getHardState', 'service_hard_state' => 'getHardState',
'service_handled' => 'isHandled', 'service_handled' => 'isHandled',
'service_unhandled' => 'isUnhandled',
'service_severity' => 'getSeverity', 'service_severity' => 'getSeverity',
'service_in_downtime' => 'isInDowntime', 'service_in_downtime' => 'isInDowntime',
'service_problem' => 'isProblem', 'service_problem' => 'isProblem',
@ -253,12 +255,16 @@ class StatusQuery extends StatusdatQuery
public function isHandled(&$host) public function isHandled(&$host)
{ {
return $host->status->current_state == 0 || return $host->status->current_state == 0 ||
$host->status->problem_has_been_acknowledged || $host->status->problem_has_been_acknowledged ||
$host->status->scheduled_downtime_depth; $host->status->scheduled_downtime_depth;
} }
public function isUnhandled(&$hostOrService)
{
return !$this->isHandled($hostOrService);
}
public function getNrOfUnhandledServices(&$obj) public function getNrOfUnhandledServices(&$obj)
{ {
$host = &$obj->host; $host = &$obj->host;
@ -329,6 +335,11 @@ class StatusQuery extends StatusdatQuery
return $this->isHandled($obj->host); return $this->isHandled($obj->host);
} }
public function isHostUnhandled(&$obj)
{
return $this->isUnhandled($obj->host);
}
public function getSeverityForHost(&$obj) public function getSeverityForHost(&$obj)
{ {
return $this->getSeverity($obj->host); return $this->getSeverity($obj->host);

View File

@ -23,6 +23,7 @@ class HostStatus extends DataView
'host_state', 'host_state',
'host_state_type', 'host_state_type',
'host_handled', 'host_handled',
'host_unhandled',
'host_in_downtime', 'host_in_downtime',
'host_acknowledged', 'host_acknowledged',
'host_last_state_change', 'host_last_state_change',
@ -105,7 +106,7 @@ class HostStatus extends DataView
public function getFilterColumns() public function getFilterColumns()
{ {
return array('hostgroups', 'servicegroups', 'service_problem'); return array('hostgroup', 'servicegroup', 'service_problems');
} }
public function isValidFilterTarget($column) public function isValidFilterTarget($column)

View File

@ -26,6 +26,7 @@ class ServiceStatus extends DataView
'service_in_downtime', 'service_in_downtime',
'service_acknowledged', 'service_acknowledged',
'service_handled', 'service_handled',
'service_unhandled',
'service_output', 'service_output',
'service_last_state_change', 'service_last_state_change',
'service_icon_image', 'service_icon_image',
@ -131,7 +132,7 @@ class ServiceStatus extends DataView
public function getFilterColumns() public function getFilterColumns()
{ {
return array('hostgroups', 'servicegroups', 'service_problem'); return array('hostgroup', 'servicegroup', 'service_problems');
} }
public function isValidFilterTarget($column) public function isValidFilterTarget($column)