From b2c486bf80f282d52ea18ba0df1a6fb964310c8b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 11 Sep 2015 16:31:19 +0200 Subject: [PATCH] Add Backend queries for host and service time periods refs #9888 --- .../Backend/Ido/Query/HoststatusQuery.php | 24 +++++++++++++++++++ .../Backend/Ido/Query/ServicestatusQuery.php | 24 +++++++++++++++++++ .../Monitoring/DataView/Hoststatus.php | 4 +++- .../Monitoring/DataView/Servicestatus.php | 4 +++- .../library/Monitoring/Object/Host.php | 2 ++ .../library/Monitoring/Object/Service.php | 4 +++- 6 files changed, 59 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 307140b7a..58a97f718 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -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} */ diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php index 7e573fde0..d863eb7d1 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php @@ -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} */ diff --git a/modules/monitoring/library/Monitoring/DataView/Hoststatus.php b/modules/monitoring/library/Monitoring/DataView/Hoststatus.php index 413f175f1..291b68772 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hoststatus.php +++ b/modules/monitoring/library/Monitoring/DataView/Hoststatus.php @@ -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' ); } diff --git a/modules/monitoring/library/Monitoring/DataView/Servicestatus.php b/modules/monitoring/library/Monitoring/DataView/Servicestatus.php index f12c66535..858da6bad 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicestatus.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicestatus.php @@ -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' ); } diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 145f7c7c2..424561285 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -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'; diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 0294bb852..1bc5afb9e 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -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);