Add Backend queries for host and service time periods

refs #9888
This commit is contained in:
Matthias Jentsch 2015-09-11 16:31:19 +02:00
parent d00e854f4b
commit b2c486bf80
6 changed files with 59 additions and 3 deletions

View File

@ -157,6 +157,12 @@ class HoststatusQuery extends IdoQuery
'service' => 'so.name2 COLLATE latin1_general_ci',
'service_description' => 'so.name2',
'service_display_name' => 's.display_name COLLATE latin1_general_ci',
),
'checktimeperiods' => array(
'host_check_timeperiod_alias' => 'ctp.alias COLLATE latin1_general_ci'
),
'notificationtimeperiods' => array(
'host_notification_timeperiod_alias' => 'ntp.alias COLLATE latin1_general_ci'
)
);
@ -266,6 +272,24 @@ class HoststatusQuery extends IdoQuery
);
}
protected function joinNotificationtimeperiods()
{
$this->select->joinLeft(
array('ntp' => $this->prefix . 'timeperiods'),
'ntp.timeperiod_object_id = h.notification_timeperiod_object_id',
array()
);
}
protected function joinChecktimeperiods()
{
$this->select->joinLeft(
array('ctp' => $this->prefix . 'timeperiods'),
'ctp.timeperiod_object_id = h.check_timeperiod_object_id',
array()
);
}
/**
* {@inheritdoc}
*/

View File

@ -269,6 +269,12 @@ class ServicestatusQuery extends IdoQuery
'service_state_type' => 'ss.state_type',
'service_status_update_time' => 'ss.status_update_time',
'service_unhandled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) = 0 THEN 1 ELSE 0 END'
),
'checktimeperiods' => array(
'service_check_timeperiod_alias' => 'ctp.alias COLLATE latin1_general_ci'
),
'notificationtimeperiods' => array(
'service_notification_timeperiod_alias' => 'ntp.alias COLLATE latin1_general_ci'
)
);
@ -386,6 +392,24 @@ class ServicestatusQuery extends IdoQuery
);
}
protected function joinNotificationtimeperiods()
{
$this->select->joinLeft(
array('ntp' => $this->prefix . 'timeperiods'),
'ntp.timeperiod_object_id = s.notification_timeperiod_object_id',
array()
);
}
protected function joinChecktimeperiods()
{
$this->select->joinLeft(
array('ctp' => $this->prefix . 'timeperiods'),
'ctp.timeperiod_object_id = s.check_timeperiod_object_id',
array()
);
}
/**
* {@inheritdoc}
*/

View File

@ -59,7 +59,9 @@ class HostStatus extends DataView
'host_severity',
'host_problem',
'host_ipv4',
'host_acknowledgement_type'
'host_acknowledgement_type',
'host_check_timeperiod_alias',
'host_notification_timeperiod_alias'
);
}

View File

@ -93,7 +93,9 @@ class ServiceStatus extends DataView
'service_flap_detection_enabled_changed',
'service_modified_service_attributes',
'service_host_name',
'service_acknowledgement_type'
'service_acknowledgement_type',
'service_check_timeperiod_alias',
'service_notification_timeperiod_alias'
);
}

View File

@ -137,6 +137,8 @@ class Host extends MonitoredObject
'host_state',
'host_state_type',
'instance_name',
'host_check_timeperiod_alias',
'host_notification_timeperiod_alias'
);
if ($this->backend->getType() === 'livestatus') {
$columns[] = 'host_contacts';

View File

@ -163,7 +163,9 @@ class Service extends MonitoredObject
'service_perfdata',
'service_process_perfdata' => 'service_process_performance_data',
'service_state',
'service_state_type'
'service_state_type',
'service_check_timeperiod_alias',
'service_notification_timeperiod_alias'
))
->where('host_name', $this->host->getName())
->where('service_description', $this->service);