summaryrefslogtreecommitdiffstats
path: root/modules/monitoring/library/Monitoring/Backend/Ido/Query/EmptyhostgroupQuery.php
blob: a99d6b7c0d3b4fc5eaed4b68506d9f46a4c7d741 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?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)',
            'host_contact'          => '(NULL)',
            'host_contactgroup'     => '(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);
    }
}