parent
fae60f06bf
commit
faca6d53c8
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2019 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
class EmptyhostgroupQuery extends HostgroupQuery
|
||||
{
|
||||
protected $subQueryTargets = [];
|
||||
|
||||
protected $columnMap = [
|
||||
'hostgroups' => [
|
||||
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
|
||||
'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci',
|
||||
'hostgroup_name' => 'hgo.name1',
|
||||
'host_name' => '(NULL)',
|
||||
'service_description' => '(NULL)',
|
||||
'servicegroup_name' => '(NULL)'
|
||||
],
|
||||
'instances' => [
|
||||
'instance_name' => 'i.instance_name'
|
||||
]
|
||||
];
|
||||
|
||||
protected function joinBaseTables()
|
||||
{
|
||||
parent::joinBaseTables();
|
||||
|
||||
$this->select->joinLeft(
|
||||
['ehgm' => $this->prefix . 'hostgroup_members'],
|
||||
'ehgm.hostgroup_id = hg.hostgroup_id',
|
||||
[]
|
||||
);
|
||||
$this->select->group(['hgo.object_id', 'hg.hostgroup_id']);
|
||||
$this->select->having('COUNT(ehgm.hostgroup_member_id) = ?', 0);
|
||||
}
|
||||
}
|
|
@ -108,7 +108,24 @@ class HostgroupsummaryQuery extends IdoQuery
|
|||
)
|
||||
);
|
||||
$this->subQueries[] = $services;
|
||||
$this->summaryQuery = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL);
|
||||
$emptyGroups = $this->createSubQuery(
|
||||
'Emptyhostgroup',
|
||||
[
|
||||
'hostgroup_alias',
|
||||
'hostgroup_name',
|
||||
'host_handled' => new Zend_Db_Expr('NULL'),
|
||||
'host_severity' => new Zend_Db_Expr('0'),
|
||||
'host_state' => new Zend_Db_Expr('NULL'),
|
||||
'service_handled' => new Zend_Db_Expr('NULL'),
|
||||
'service_severity' => new Zend_Db_Expr('0'),
|
||||
'service_state' => new Zend_Db_Expr('NULL'),
|
||||
]
|
||||
);
|
||||
$this->subQueries[] = $emptyGroups;
|
||||
$this->summaryQuery = $this->db->select()->union(
|
||||
[$hosts, $services, $emptyGroups],
|
||||
Zend_Db_Select::SQL_UNION_ALL
|
||||
);
|
||||
$this->select->from(array('hostgroupsummary' => $this->summaryQuery), array());
|
||||
$this->group(array('hostgroup_name', 'hostgroup_alias'));
|
||||
$this->joinedVirtualTables['hostgroupsummary'] = true;
|
||||
|
|
Loading…
Reference in New Issue