Object\Host: not-so-nice workaround, LS contancts

This commit is contained in:
Thomas Gelf 2014-11-16 19:28:08 +01:00
parent 5bb3165da3
commit a8a7da4ade
2 changed files with 21 additions and 3 deletions
modules/monitoring/library/Monitoring/Object

View File

@ -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);
}

View File

@ -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;
}
/**