StatusSummaryQuery: reorganize, add new columns

refs 
This commit is contained in:
Thomas Gelf 2014-09-05 18:06:26 +02:00
parent 949ea1cc9b
commit 38c6d6aaf8
1 changed files with 24 additions and 2 deletions
modules/monitoring/library/Monitoring/Backend/Ido/Query

View File

@ -8,7 +8,15 @@ use Zend_Db_Select;
class StatusSummaryQuery extends IdoQuery class StatusSummaryQuery extends IdoQuery
{ {
protected $subHosts;
protected $subServices;
protected $columnMap = array( protected $columnMap = array(
'services' => array(
'service_host_name' => 'so.name1',
'service_description' => 'so.name2',
),
'hoststatussummary' => array( 'hoststatussummary' => array(
'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)',
'hosts_up_not_checked' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 AND is_active_checked = 0 AND is_passive_checked = 0 THEN 1 ELSE 0 END)', 'hosts_up_not_checked' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 AND is_active_checked = 0 AND is_passive_checked = 0 THEN 1 ELSE 0 END)',
@ -159,10 +167,24 @@ class StatusSummaryQuery extends IdoQuery
'object_type' => '(\'service\')' 'object_type' => '(\'service\')'
)); ));
$union = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL); $union = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL);
$this->subHosts = $hosts;
$this->subServices = $services;
$this->select->from(array('statussummary' => $union), array()); $this->select->from(array('statussummary' => $union), array());
$this->joinedVirtualTables = array( $this->joinedVirtualTables = array(
'servicestatussummary' => true, 'services' => true,
'hoststatussummary' => true 'servicestatussummary' => true,
'hoststatussummary' => true
); );
} }
public function whereToSql($col, $sign, $expression)
{
if ($col === 'so.name1') {
$this->subServices->where('so.name1 ' . $sign . ' ?', $expression);
return '';
return 'sh.state_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression));
} else {
return parent::whereToSql($col, $sign, $expression);
}
}
} }