monitoring: Rearrange code in the HoststatusQuery

refs #9956
This commit is contained in:
Eric Lippmann 2015-09-29 22:44:12 +02:00
parent 02eee7a603
commit d0f11e10f6
1 changed files with 29 additions and 26 deletions

View File

@ -26,8 +26,8 @@ class HoststatusQuery extends IdoQuery
* {@inheritdoc}
*/
protected $columnMap = array(
'instances' => array(
'instance_name' => 'i.instance_name'
'checktimeperiods' => array(
'host_check_timeperiod' => 'ctp.alias COLLATE latin1_general_ci'
),
'hostgroups' => array(
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
@ -158,6 +158,9 @@ class HoststatusQuery extends IdoQuery
'host_status_update_time' => 'hs.status_update_time',
'host_unhandled' => 'CASE WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) = 0 THEN 1 ELSE 0 END'
),
'instances' => array(
'instance_name' => 'i.instance_name'
),
'servicegroups' => array(
'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci',
'servicegroup_name' => 'sgo.name1',
@ -167,9 +170,6 @@ class HoststatusQuery extends IdoQuery
'service' => 'so.name2 COLLATE latin1_general_ci',
'service_description' => 'so.name2',
'service_display_name' => 's.display_name COLLATE latin1_general_ci',
),
'checktimeperiods' => array(
'host_check_timeperiod' => 'ctp.alias COLLATE latin1_general_ci'
)
);
@ -197,6 +197,18 @@ class HoststatusQuery extends IdoQuery
$this->joinedVirtualTables['hosts'] = true;
}
/**
* Join check time periods
*/
protected function joinChecktimeperiods()
{
$this->select->joinLeft(
array('ctp' => $this->prefix . 'timeperiods'),
'ctp.timeperiod_object_id = h.check_timeperiod_object_id',
array()
);
}
/**
* Join host groups
*/
@ -229,6 +241,18 @@ class HoststatusQuery extends IdoQuery
);
}
/**
* Join instances
*/
protected function joinInstances()
{
$this->select->join(
array('i' => $this->prefix . 'instances'),
'i.instance_id = ho.instance_id',
array()
);
}
/**
* Join service groups
*/
@ -267,27 +291,6 @@ class HoststatusQuery extends IdoQuery
);
}
/**
* Join instances
*/
protected function joinInstances()
{
$this->select->join(
array('i' => $this->prefix . 'instances'),
'i.instance_id = ho.instance_id',
array()
);
}
protected function joinChecktimeperiods()
{
$this->select->joinLeft(
array('ctp' => $this->prefix . 'timeperiods'),
'ctp.timeperiod_object_id = h.check_timeperiod_object_id',
array()
);
}
/**
* Query the service problem summary for all hosts of this query's result set
*