Prepare AbstractObject for farther performance tuning
This commit is contained in:
parent
3b2272f825
commit
b37c902e2d
|
@ -1,5 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
CREATE INDEX tgelf_comments ON icinga_comments (object_id, comment_type, comment_time);
|
||||||
|
|
||||||
|
CREATE INDEX tgelf_scheduleddowntime ON icinga_scheduleddowntime (object_id, is_in_effect, scheduled_start_time);
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Object;
|
namespace Icinga\Module\Monitoring\Object;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\DataView\Contact;
|
use Icinga\Module\Monitoring\DataView\Contact;
|
||||||
|
@ -87,6 +94,7 @@ abstract class AbstractObject
|
||||||
if ($this->type === 'service') {
|
if ($this->type === 'service') {
|
||||||
$query->where('downtime_service', $this->service_description);
|
$query->where('downtime_service', $this->service_description);
|
||||||
}
|
}
|
||||||
|
$query->order('downtime_is_in_effect', 'DESC')->order('downtime_scheduled_start', 'ASC');
|
||||||
|
|
||||||
$this->downtimes = $query->fetchAll();
|
$this->downtimes = $query->fetchAll();
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -97,14 +105,15 @@ abstract class AbstractObject
|
||||||
|
|
||||||
public function fetchHostgroups()
|
public function fetchHostgroups()
|
||||||
{
|
{
|
||||||
$this->hostgroups = Hostgroup::fromRequest(
|
$query = Hostgroup::fromRequest(
|
||||||
$this->request,
|
$this->request,
|
||||||
array(
|
array(
|
||||||
'hostgroup_name',
|
'hostgroup_name',
|
||||||
'hostgroup_alias'
|
'hostgroup_alias'
|
||||||
)
|
)
|
||||||
)->getQuery()->fetchPairs();
|
)->getQuery();
|
||||||
|
|
||||||
|
$this->hostgroups = $query->fetchPairs();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +142,7 @@ abstract class AbstractObject
|
||||||
|
|
||||||
public function fetchContacts()
|
public function fetchContacts()
|
||||||
{
|
{
|
||||||
$this->contacts = Contact::fromRequest(
|
$query = Contact::fromRequest(
|
||||||
$this->request,
|
$this->request,
|
||||||
array(
|
array(
|
||||||
'contact_name',
|
'contact_name',
|
||||||
|
@ -142,39 +151,44 @@ abstract class AbstractObject
|
||||||
'contact_pager',
|
'contact_pager',
|
||||||
)
|
)
|
||||||
)->getQuery()
|
)->getQuery()
|
||||||
->where('host_name', $this->host_name)
|
->where('host_name', $this->host_name);
|
||||||
->fetchAll();
|
|
||||||
|
$this->contacts = $query->fetchAll();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetchServicegroups()
|
public function fetchServicegroups()
|
||||||
{
|
{
|
||||||
$this->servicegroups = Servicegroup::fromRequest(
|
$query = Servicegroup::fromRequest(
|
||||||
$this->request,
|
$this->request,
|
||||||
array(
|
array(
|
||||||
'servicegroup_name',
|
'servicegroup_name',
|
||||||
'servicegroup_alias',
|
'servicegroup_alias',
|
||||||
)
|
)
|
||||||
)->getQuery()->fetchPairs();
|
)->getQuery();
|
||||||
|
|
||||||
|
$this->servicegroups = $query->fetchPairs();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetchContactgroups()
|
public function fetchContactgroups()
|
||||||
{
|
{
|
||||||
$this->contactgroups = Contactgroup::fromRequest(
|
$query = Contactgroup::fromRequest(
|
||||||
$this->request,
|
$this->request,
|
||||||
array(
|
array(
|
||||||
'contactgroup_name',
|
'contactgroup_name',
|
||||||
'contactgroup_alias'
|
'contactgroup_alias'
|
||||||
)
|
)
|
||||||
)->getQuery()->fetchAll();
|
)->getQuery();
|
||||||
|
|
||||||
|
$this->contactgroups = $query->fetchAll();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetchEventHistory()
|
public function fetchEventHistory()
|
||||||
{
|
{
|
||||||
$this->eventhistory = EventHistory::fromRequest(
|
$query = EventHistory::fromRequest(
|
||||||
$this->request,
|
$this->request,
|
||||||
array(
|
array(
|
||||||
'object_type',
|
'object_type',
|
||||||
|
@ -188,6 +202,8 @@ abstract class AbstractObject
|
||||||
'type'
|
'type'
|
||||||
)
|
)
|
||||||
)->sort('raw_timestamp', 'DESC')->getQuery();
|
)->sort('raw_timestamp', 'DESC')->getQuery();
|
||||||
|
|
||||||
|
$this->eventhistory = $query;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue