2013-09-24 15:26:10 +02:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2013-09-24 15:26:10 +02:00
|
|
|
|
|
|
|
namespace Icinga\Module\Monitoring\DataView;
|
|
|
|
|
2013-10-14 13:25:25 +02:00
|
|
|
class ServiceStatus extends DataView
|
2013-09-24 15:26:10 +02:00
|
|
|
{
|
2014-10-08 12:30:08 +02:00
|
|
|
/**
|
|
|
|
* Sets the mode for `distinct as workaround
|
|
|
|
*
|
|
|
|
* @TODO Subject to change, see #7344
|
|
|
|
*/
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->query->setMode('service');
|
|
|
|
}
|
|
|
|
|
2013-09-24 15:26:10 +02:00
|
|
|
/**
|
|
|
|
* Retrieve columns provided by this view
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getColumns()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'host_name',
|
2015-01-21 09:15:07 +01:00
|
|
|
'host_display_name',
|
2013-09-24 15:26:10 +02:00
|
|
|
'host_state',
|
|
|
|
'host_state_type',
|
|
|
|
'host_last_state_change',
|
|
|
|
'host_address',
|
2014-03-07 16:43:22 +01:00
|
|
|
'host_problem',
|
2013-09-24 15:26:10 +02:00
|
|
|
'host_handled',
|
|
|
|
'service_description',
|
|
|
|
'service_display_name',
|
|
|
|
'service_state',
|
|
|
|
'service_in_downtime',
|
|
|
|
'service_acknowledged',
|
|
|
|
'service_handled',
|
2013-10-22 14:27:19 +02:00
|
|
|
'service_unhandled',
|
2013-09-24 15:26:10 +02:00
|
|
|
'service_output',
|
|
|
|
'service_last_state_change',
|
|
|
|
'service_long_output',
|
|
|
|
'service_is_flapping',
|
|
|
|
'service_state_type',
|
|
|
|
'service_severity',
|
|
|
|
'service_last_check',
|
|
|
|
'service_notifications_enabled',
|
2013-10-20 13:15:11 +02:00
|
|
|
'service_notifications_enabled_changed',
|
2013-09-24 15:26:10 +02:00
|
|
|
'service_action_url',
|
|
|
|
'service_notes_url',
|
|
|
|
'service_last_comment',
|
2014-06-25 21:38:55 +02:00
|
|
|
'service_last_downtime',
|
|
|
|
'service_last_flapping',
|
|
|
|
'service_last_ack',
|
2013-10-15 19:56:33 +02:00
|
|
|
'service_last_check',
|
|
|
|
'service_next_check',
|
2013-10-19 20:09:17 +02:00
|
|
|
'service_attempt',
|
2013-10-15 19:56:33 +02:00
|
|
|
'service_last_notification',
|
|
|
|
'service_check_command',
|
2014-03-08 21:02:22 +01:00
|
|
|
'service_current_notification_number',
|
2013-09-24 15:26:10 +02:00
|
|
|
'host_acknowledged',
|
|
|
|
'host_output',
|
|
|
|
'host_long_output',
|
|
|
|
'host_in_downtime',
|
|
|
|
'host_is_flapping',
|
|
|
|
'host_last_check',
|
|
|
|
'host_notifications_enabled',
|
|
|
|
'host_unhandled_service_count',
|
|
|
|
'host_action_url',
|
|
|
|
'host_notes_url',
|
|
|
|
'host_last_comment',
|
|
|
|
'host_display_name',
|
|
|
|
'host_alias',
|
|
|
|
'host_ipv4',
|
|
|
|
'host_severity',
|
|
|
|
'host_perfdata',
|
2014-05-20 20:07:09 +02:00
|
|
|
'host_check_source',
|
2013-10-15 19:56:33 +02:00
|
|
|
'host_active_checks_enabled',
|
|
|
|
'host_passive_checks_enabled',
|
2013-09-24 15:26:10 +02:00
|
|
|
'host_last_hard_state',
|
|
|
|
'host_last_hard_state_change',
|
|
|
|
'host_last_time_up',
|
|
|
|
'host_last_time_down',
|
|
|
|
'host_last_time_unreachable',
|
2013-10-20 13:15:11 +02:00
|
|
|
'host_modified_host_attributes',
|
2013-09-24 15:26:10 +02:00
|
|
|
'service_hard_state',
|
2013-10-21 17:42:29 +02:00
|
|
|
'service_problem',
|
2013-09-24 15:26:10 +02:00
|
|
|
'service_perfdata',
|
2014-05-20 22:36:39 +02:00
|
|
|
'service_check_source',
|
2013-10-15 19:56:33 +02:00
|
|
|
'service_active_checks_enabled',
|
2013-10-20 13:15:11 +02:00
|
|
|
'service_active_checks_enabled_changed',
|
2013-10-15 19:56:33 +02:00
|
|
|
'service_passive_checks_enabled',
|
2013-10-20 13:15:11 +02:00
|
|
|
'service_passive_checks_enabled_changed',
|
2013-09-24 15:26:10 +02:00
|
|
|
'service_last_hard_state',
|
|
|
|
'service_last_hard_state_change',
|
|
|
|
'service_last_time_ok',
|
|
|
|
'service_last_time_warning',
|
|
|
|
'service_last_time_critical',
|
|
|
|
'service_last_time_unknown',
|
2013-09-26 16:29:48 +02:00
|
|
|
'service_current_check_attempt',
|
2013-10-20 13:15:11 +02:00
|
|
|
'service_max_check_attempts',
|
|
|
|
'service_obsessing',
|
|
|
|
'service_obsessing_changed',
|
|
|
|
'service_event_handler_enabled',
|
|
|
|
'service_event_handler_enabled_changed',
|
|
|
|
'service_flap_detection_enabled',
|
|
|
|
'service_flap_detection_enabled_changed',
|
|
|
|
'service_modified_service_attributes',
|
2014-10-06 11:37:33 +02:00
|
|
|
'service_host_name'
|
2013-09-24 15:26:10 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-04-17 13:59:11 +02:00
|
|
|
public static function getQueryName()
|
2013-09-24 15:26:10 +02:00
|
|
|
{
|
|
|
|
return 'status';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSortRules()
|
|
|
|
{
|
|
|
|
return array(
|
2015-03-13 17:19:56 +01:00
|
|
|
'service_display_name' => array(
|
|
|
|
'columns' => array(
|
|
|
|
'service_display_name',
|
|
|
|
'host_display_name'
|
|
|
|
),
|
|
|
|
'order' => self::SORT_ASC
|
|
|
|
),
|
2015-01-21 09:37:45 +01:00
|
|
|
'service_severity' => array(
|
2014-04-17 18:25:32 +02:00
|
|
|
'columns' => array(
|
2015-05-21 12:17:25 +02:00
|
|
|
'service_severity',
|
2015-05-15 10:54:30 +02:00
|
|
|
'service_last_state_change DESC',
|
2015-03-13 17:13:52 +01:00
|
|
|
'service_display_name ASC',
|
|
|
|
'host_display_name ASC'
|
2015-05-21 12:17:25 +02:00
|
|
|
),
|
|
|
|
'order' => self::SORT_DESC
|
2013-09-24 15:26:10 +02:00
|
|
|
),
|
2015-03-13 17:13:52 +01:00
|
|
|
'host_severity' => array(
|
|
|
|
'columns' => array(
|
2015-05-21 12:17:25 +02:00
|
|
|
'host_severity',
|
2015-05-15 10:54:30 +02:00
|
|
|
'host_last_state_change DESC',
|
2015-03-13 17:13:52 +01:00
|
|
|
'host_display_name ASC',
|
|
|
|
'service_display_name ASC'
|
2015-05-21 12:17:25 +02:00
|
|
|
),
|
|
|
|
'order' => self::SORT_DESC
|
2015-03-13 17:13:52 +01:00
|
|
|
),
|
2015-01-21 09:37:45 +01:00
|
|
|
'host_display_name' => array(
|
2013-09-24 15:26:10 +02:00
|
|
|
'columns' => array(
|
2015-01-21 09:37:45 +01:00
|
|
|
'host_display_name',
|
|
|
|
'service_display_name'
|
2013-09-24 15:26:10 +02:00
|
|
|
),
|
|
|
|
'order' => self::SORT_ASC
|
2014-02-18 20:42:18 +01:00
|
|
|
),
|
2015-01-21 09:37:45 +01:00
|
|
|
'host_address' => array(
|
2014-02-18 20:42:18 +01:00
|
|
|
'columns' => array(
|
2015-01-21 09:37:45 +01:00
|
|
|
'host_ipv4',
|
|
|
|
'service_display_name'
|
2014-02-18 20:42:18 +01:00
|
|
|
),
|
2015-01-21 09:37:45 +01:00
|
|
|
'order' => self::SORT_ASC
|
2013-09-24 15:26:10 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFilterColumns()
|
|
|
|
{
|
2015-04-09 11:41:56 +02:00
|
|
|
return array(
|
|
|
|
'host',
|
|
|
|
'hostgroup',
|
2015-06-05 15:49:26 +02:00
|
|
|
'hostgroup_alias',
|
2015-04-09 11:41:56 +02:00
|
|
|
'hostgroup_name',
|
|
|
|
'service',
|
|
|
|
'service_host',
|
|
|
|
'servicegroup',
|
2015-06-05 15:49:26 +02:00
|
|
|
'servicegroup_alias',
|
2015-04-09 11:41:56 +02:00
|
|
|
'servicegroup_name'
|
|
|
|
);
|
2013-09-24 15:26:10 +02:00
|
|
|
}
|
|
|
|
|
2013-10-14 13:25:25 +02:00
|
|
|
public function isValidFilterTarget($column)
|
2013-09-24 15:26:10 +02:00
|
|
|
{
|
|
|
|
if ($column[0] === '_'
|
|
|
|
&& preg_match('/^_(?:host|service)_/', $column)
|
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-10-14 13:25:25 +02:00
|
|
|
return parent::isValidFilterTarget($column);
|
2013-09-24 15:26:10 +02:00
|
|
|
}
|
2015-05-19 17:50:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getSearchColumns()
|
|
|
|
{
|
2015-06-25 12:24:52 +02:00
|
|
|
return array('host', 'host_display_name', 'service', 'service_display_name');
|
2015-05-19 17:50:07 +02:00
|
|
|
}
|
2013-09-24 15:26:10 +02:00
|
|
|
}
|