MonitoredObject: Support host- and servicegroup filters in method matches()

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-23 13:03:41 +02:00
parent e42548fc80
commit 40c2cb2d12

View File

@ -229,16 +229,35 @@ abstract class MonitoredObject implements Filterable
); );
} }
$queryString = $filter->toQueryString();
$row = clone $this->properties; $row = clone $this->properties;
if ($this->customvars === null) { if (strpos($queryString, '_host_') !== false || strpos($queryString, '_service_') !== false) {
$this->fetchCustomvars(); if ($this->customvars === null) {
$this->fetchCustomvars();
}
foreach ($this->customvars as $name => $value) {
if (! is_object($value)) {
$row->{'_' . $this->getType() . '_' . strtolower(str_replace(' ', '_', $name))} = $value;
}
}
} }
foreach ($this->customvars as $name => $value) { if (strpos($queryString, 'hostgroup_name') !== false) {
if (! is_object($value)) { if ($this->hostgroups === null) {
$row->{'_' . $this->getType() . '_' . strtolower(str_replace(' ', '_', $name))} = $value; $this->fetchHostgroups();
} }
$row->hostgroup_name = array_keys($this->hostgroups);
}
if (strpos($queryString, 'servicegroup_name') !== false) {
if ($this->servicegroups === null) {
$this->fetchServicegroups();
}
$row->servicegroup_name = array_keys($this->servicegroups);
} }
return $filter->matches($row); return $filter->matches($row);