From c55c5a9e64e56c8b6075663620eac3d75b53f867 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 31 Aug 2016 12:59:39 +0200 Subject: [PATCH] IDO: Provide downtime name column The Icinga 2 API requires the downtimes's name when removing the downtime. refs #11398 --- .../library/Monitoring/Backend/Ido/Query/DowntimeQuery.php | 4 ++++ .../Monitoring/Backend/Ido/Query/HostdowntimeQuery.php | 4 ++++ .../Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php | 4 ++++ modules/monitoring/library/Monitoring/DataView/Downtime.php | 1 + .../monitoring/library/Monitoring/DataView/Hostdowntime.php | 1 + .../library/Monitoring/DataView/Servicedowntime.php | 1 + 6 files changed, 15 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php index ae0c08d9c..2c85c1547 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -27,6 +27,7 @@ class DowntimeQuery extends IdoQuery 'downtime_is_fixed' => 'd.downtime_is_fixed', 'downtime_is_flexible' => 'd.downtime_is_flexible', 'downtime_is_in_effect' => 'd.downtime_is_in_effect', + 'downtime_name' => 'd.downtime_name', 'downtime_scheduled_end' => 'd.downtime_scheduled_end', 'downtime_scheduled_start' => 'd.downtime_scheduled_start', 'downtime_start' => 'd.downtime_start', @@ -90,6 +91,9 @@ class DowntimeQuery extends IdoQuery */ protected function joinBaseTables() { + if (version_compare($this->getIdoVersion(), '1.14.0', '<')) { + $this->columnMap['downtimes']['downtime_name'] = '(NULL)'; + } $this->downtimeQuery = $this->db->select(); $this->select->from( array('d' => $this->downtimeQuery), diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeQuery.php index b3be3420b..3bea210de 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeQuery.php @@ -38,6 +38,7 @@ class HostdowntimeQuery extends IdoQuery 'downtime_is_fixed' => 'sd.is_fixed', 'downtime_is_flexible' => 'CASE WHEN sd.is_fixed = 0 THEN 1 ELSE 0 END', 'downtime_is_in_effect' => 'sd.is_in_effect', + 'downtime_name' => 'sd.name', 'downtime_scheduled_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_time)', 'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)', 'downtime_start' => 'UNIX_TIMESTAMP(CASE WHEN UNIX_TIMESTAMP(sd.trigger_time) > 0 then sd.trigger_time ELSE sd.scheduled_start_time END)', @@ -78,6 +79,9 @@ class HostdowntimeQuery extends IdoQuery */ protected function joinBaseTables() { + if (version_compare($this->getIdoVersion(), '1.14.0', '<')) { + $this->columnMap['downtimes']['downtime_name'] = '(NULL)'; + } $this->select->from( array('sd' => $this->prefix . 'scheduleddowntime'), array() diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php index c0b0fca2a..2c370bea9 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php @@ -38,6 +38,7 @@ class ServicedowntimeQuery extends IdoQuery 'downtime_is_fixed' => 'sd.is_fixed', 'downtime_is_flexible' => 'CASE WHEN sd.is_fixed = 0 THEN 1 ELSE 0 END', 'downtime_is_in_effect' => 'sd.is_in_effect', + 'downtime_name' => 'sd.name', 'downtime_scheduled_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_time)', 'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)', 'downtime_start' => 'UNIX_TIMESTAMP(CASE WHEN UNIX_TIMESTAMP(sd.trigger_time) > 0 then sd.trigger_time ELSE sd.scheduled_start_time END)', @@ -83,6 +84,9 @@ class ServicedowntimeQuery extends IdoQuery */ protected function joinBaseTables() { + if (version_compare($this->getIdoVersion(), '1.14.0', '<')) { + $this->columnMap['downtimes']['downtime_name'] = '(NULL)'; + } $this->select->from( array('sd' => $this->prefix . 'scheduleddowntime'), array() diff --git a/modules/monitoring/library/Monitoring/DataView/Downtime.php b/modules/monitoring/library/Monitoring/DataView/Downtime.php index 8e14a13ee..ca42e2da5 100644 --- a/modules/monitoring/library/Monitoring/DataView/Downtime.php +++ b/modules/monitoring/library/Monitoring/DataView/Downtime.php @@ -23,6 +23,7 @@ class Downtime extends DataView 'downtime_is_fixed', 'downtime_is_flexible', 'downtime_is_in_effect', + 'downtime_name', 'downtime_scheduled_end', 'downtime_scheduled_start', 'downtime_start', diff --git a/modules/monitoring/library/Monitoring/DataView/Hostdowntime.php b/modules/monitoring/library/Monitoring/DataView/Hostdowntime.php index 8782b33fe..f5e4e8005 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostdowntime.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostdowntime.php @@ -24,6 +24,7 @@ class Hostdowntime extends DataView 'downtime_is_fixed', 'downtime_is_flexible', 'downtime_is_in_effect', + 'downtime_name', 'downtime_scheduled_end', 'downtime_scheduled_start', 'downtime_start', diff --git a/modules/monitoring/library/Monitoring/DataView/Servicedowntime.php b/modules/monitoring/library/Monitoring/DataView/Servicedowntime.php index baed8c195..43d895ede 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicedowntime.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicedowntime.php @@ -21,6 +21,7 @@ class Servicedowntime extends DataView 'downtime_is_fixed', 'downtime_is_flexible', 'downtime_is_in_effect', + 'downtime_name', 'downtime_scheduled_end', 'downtime_scheduled_start', 'downtime_start',