mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
monitoring/MonitoredObject': Use
host_name' and `service_description' for filtering
This commit is contained in:
parent
44c4ec751d
commit
c04768ee8f
@ -162,6 +162,19 @@ abstract class MonitoredObject
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the object's properties
|
||||||
|
*
|
||||||
|
* @param object $properties
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setProperties($properties)
|
||||||
|
{
|
||||||
|
$this->properties = (object) $properties;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the object's comments
|
* Fetch the object's comments
|
||||||
*
|
*
|
||||||
@ -178,9 +191,9 @@ abstract class MonitoredObject
|
|||||||
))
|
))
|
||||||
->where('comment_type', array('comment', 'ack'))
|
->where('comment_type', array('comment', 'ack'))
|
||||||
->where('comment_objecttype', $this->type)
|
->where('comment_objecttype', $this->type)
|
||||||
->where('comment_host', $this->host);
|
->where('comment_host', $this->host_name);
|
||||||
if ($this->type === self::TYPE_SERVICE) {
|
if ($this->type === self::TYPE_SERVICE) {
|
||||||
$comments->where('comment_service', $this->service);
|
$comments->where('comment_service', $this->service_description);
|
||||||
}
|
}
|
||||||
$this->comments = $comments->getQuery()->fetchAll();
|
$this->comments = $comments->getQuery()->fetchAll();
|
||||||
return $this;
|
return $this;
|
||||||
@ -210,11 +223,11 @@ abstract class MonitoredObject
|
|||||||
'service' => 'downtime_service'
|
'service' => 'downtime_service'
|
||||||
))
|
))
|
||||||
->where('downtime_objecttype', $this->type)
|
->where('downtime_objecttype', $this->type)
|
||||||
->where('downtime_host', $this->host)
|
->where('downtime_host', $this->host_name)
|
||||||
->order('downtime_is_in_effect', 'DESC')
|
->order('downtime_is_in_effect', 'DESC')
|
||||||
->order('downtime_scheduled_start', 'ASC');
|
->order('downtime_scheduled_start', 'ASC');
|
||||||
if ($this->type === self::TYPE_SERVICE) {
|
if ($this->type === self::TYPE_SERVICE) {
|
||||||
$downtimes->where('downtime_service', $this->service);
|
$downtimes->where('downtime_service', $this->service_description);
|
||||||
}
|
}
|
||||||
$this->downtimes = $downtimes->getQuery()->fetchAll();
|
$this->downtimes = $downtimes->getQuery()->fetchAll();
|
||||||
return $this;
|
return $this;
|
||||||
@ -265,9 +278,9 @@ abstract class MonitoredObject
|
|||||||
'varvalue'
|
'varvalue'
|
||||||
))
|
))
|
||||||
->where('object_type', $this->type)
|
->where('object_type', $this->type)
|
||||||
->where('host_name', $this->host);
|
->where('host_name', $this->host_name);
|
||||||
if ($this->type === self::TYPE_SERVICE) {
|
if ($this->type === self::TYPE_SERVICE) {
|
||||||
$query->where('service_description', $this->service);
|
$query->where('service_description', $this->service_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->customvars = array();
|
$this->customvars = array();
|
||||||
@ -299,7 +312,7 @@ abstract class MonitoredObject
|
|||||||
))
|
))
|
||||||
->where('host_name', $this->host_name);
|
->where('host_name', $this->host_name);
|
||||||
if ($this->type === self::TYPE_SERVICE) {
|
if ($this->type === self::TYPE_SERVICE) {
|
||||||
$contacts->where('service_description', $this->service);
|
$contacts->where('service_description', $this->service_description);
|
||||||
}
|
}
|
||||||
$this->contacts = $contacts->getQuery()->fetchAll();
|
$this->contacts = $contacts->getQuery()->fetchAll();
|
||||||
return $this;
|
return $this;
|
||||||
@ -316,8 +329,8 @@ abstract class MonitoredObject
|
|||||||
'servicegroup_name',
|
'servicegroup_name',
|
||||||
'servicegroup_alias'
|
'servicegroup_alias'
|
||||||
))
|
))
|
||||||
->where('service_host_name', $this->host)
|
->where('service_host_name', $this->host_name)
|
||||||
->where('service_description', $this->service);
|
->where('service_description', $this->service_description);
|
||||||
$this->servicegroups = $serviceGroups->getQuery()->fetchPairs();
|
$this->servicegroups = $serviceGroups->getQuery()->fetchPairs();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -333,9 +346,9 @@ abstract class MonitoredObject
|
|||||||
'contactgroup_name',
|
'contactgroup_name',
|
||||||
'contactgroup_alias'
|
'contactgroup_alias'
|
||||||
))
|
))
|
||||||
->where('host_name', $this->host);
|
->where('host_name', $this->host_name);
|
||||||
if ($this->type === self::TYPE_SERVICE) {
|
if ($this->type === self::TYPE_SERVICE) {
|
||||||
$contactsGroups->where('service_description', $this->service);
|
$contactsGroups->where('service_description', $this->service_description);
|
||||||
}
|
}
|
||||||
$this->contactgroups = $contactsGroups->getQuery()->fetchAll();
|
$this->contactgroups = $contactsGroups->getQuery()->fetchAll();
|
||||||
return $this;
|
return $this;
|
||||||
@ -360,9 +373,9 @@ abstract class MonitoredObject
|
|||||||
'type'
|
'type'
|
||||||
))
|
))
|
||||||
->order('timestamp', 'DESC')
|
->order('timestamp', 'DESC')
|
||||||
->where('host_name', $this->host);
|
->where('host_name', $this->host_name);
|
||||||
if ($this->type === self::TYPE_SERVICE) {
|
if ($this->type === self::TYPE_SERVICE) {
|
||||||
$eventHistory->where('service_description', $this->service);
|
$eventHistory->where('service_description', $this->service_description);
|
||||||
}
|
}
|
||||||
$this->eventhistory = $eventHistory->getQuery();
|
$this->eventhistory = $eventHistory->getQuery();
|
||||||
return $this;
|
return $this;
|
||||||
@ -398,10 +411,12 @@ abstract class MonitoredObject
|
|||||||
$this->$fetchMethod();
|
$this->$fetchMethod();
|
||||||
return $this->$name;
|
return $this->$name;
|
||||||
}
|
}
|
||||||
if (substr($name, 0, strlen($this->prefix)) === $this->prefix) {
|
if (substr($name, 0, strlen($this->prefix)) !== $this->prefix) {
|
||||||
throw new InvalidPropertyException('Can\'t access property \'%s\'. Property does not exist.', $name);
|
$prefixedName = $this->prefix . strtolower($name);
|
||||||
|
if (property_exists($this->properties, $prefixedName)) {
|
||||||
|
return $this->properties->$prefixedName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$prefixedName = $this->prefix . strtolower($name);
|
throw new InvalidPropertyException('Can\'t access property \'%s\'. Property does not exist.', $name);
|
||||||
return $this->$prefixedName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user