From a8a7da4ade48ad9dd27664f3c15113a343d26a3c Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 16 Nov 2014 19:28:08 +0100 Subject: [PATCH] Object\Host: not-so-nice workaround, LS contancts --- .../library/Monitoring/Object/Host.php | 8 ++++++-- .../Monitoring/Object/MonitoredObject.php | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 831579a57..fd08f6a20 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -89,7 +89,7 @@ class Host extends MonitoredObject */ protected function getDataView() { - return $this->backend->select()->from('hostStatus', array( + $columns = array( 'host_name', 'host_alias', 'host_address', @@ -132,7 +132,11 @@ class Host extends MonitoredObject 'host_problem', 'host_process_performance_data', 'process_perfdata' => 'host_process_performance_data' - )) + ); + if ($this->backend->getType() === 'livestatus') { + $columns[] = 'host_contacts'; + } + return $this->backend->select()->from('hostStatus', $columns) ->where('host_name', $this->host); } diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 99e9c0e47..fefcba929 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -141,7 +141,21 @@ abstract class MonitoredObject public function fetch() { $this->properties = $this->getDataView()->getQuery()->fetchRow(); - return $this->properties !== false; + if ($this->properties === false) { + return false; + } + if (isset($this->properties->host_contacts)) { + $this->contacts = array(); + foreach (preg_split('~,~', $this->properties->host_contacts) as $contact) { + $this->contacts[] = (object) array( + 'contact_name' => $contact, + 'contact_alias' => $contact, + 'contact_email' => null, + 'contact_pager' => null, + ); + } + } + return true; } /**