Allow to filter for contact groups

This commit is contained in:
Eric Lippmann 2019-07-08 18:00:14 +02:00
parent 523a35f4c1
commit bcc867d48e
8 changed files with 133 additions and 5 deletions

View File

@ -29,6 +29,9 @@ class HostgroupQuery extends IdoQuery
'contacts' => [ 'contacts' => [
'host_contact' => 'hco.name1' 'host_contact' => 'hco.name1'
], ],
'contactgroups' => [
'host_contactgroup' => 'hcgo.name1'
],
'hostgroups' => array( 'hostgroups' => array(
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci', 'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci',
@ -146,6 +149,24 @@ class HostgroupQuery extends IdoQuery
); );
} }
/**
* Join contact groups
*/
protected function joinContactgroups()
{
$this->requireVirtualTable('hosts');
$this->select->joinLeft(
['hcg' => 'icinga_host_contactgroups'],
'hcg.host_id = h.host_id',
[]
)->joinLeft(
['hcgo' => 'icinga_objects'],
'hcgo.object_id = hcg.contactgroup_object_id AND hcgo.is_active = 1 AND hcgo.objecttype_id = 11',
[]
);
}
/** /**
* Join hosts * Join hosts
*/ */

View File

@ -35,6 +35,9 @@ class HoststatusQuery extends IdoQuery
'contacts' => [ 'contacts' => [
'host_contact' => 'hco.name1' 'host_contact' => 'hco.name1'
], ],
'contactgroups' => [
'host_contactgroup' => 'hcgo.name1'
],
'hostgroups' => array( 'hostgroups' => array(
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci', 'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci',
@ -220,6 +223,22 @@ class HoststatusQuery extends IdoQuery
); );
} }
/**
* Join contact groups
*/
protected function joinContactgroups()
{
$this->select->joinLeft(
['hcg' => 'icinga_host_contactgroups'],
'hcg.host_id = h.host_id',
[]
)->joinLeft(
['hcgo' => 'icinga_objects'],
'hcgo.object_id = hcg.contactgroup_object_id AND hcgo.is_active = 1 AND hcgo.objecttype_id = 11',
[]
);
}
/** /**
* Join host groups * Join host groups
*/ */

View File

@ -25,9 +25,15 @@ class ServicegroupQuery extends IdoQuery
'contacts' => [ 'contacts' => [
'service_contact' => 'sco.name1' 'service_contact' => 'sco.name1'
], ],
'contactgroups' => [
'service_contactgroup' => 'scgo.name1'
],
'hostcontacts' => [ 'hostcontacts' => [
'host_contact' => 'hco.name1' 'host_contact' => 'hco.name1'
], ],
'hostcontactgroups' => [
'host_contactgroup' => 'hcgo.name1'
],
'hostgroups' => array( 'hostgroups' => array(
'hostgroup_name' => 'hgo.name1' 'hostgroup_name' => 'hgo.name1'
), ),
@ -120,6 +126,24 @@ class ServicegroupQuery extends IdoQuery
); );
} }
/**
* Join contact groups
*/
protected function joinContactgroups()
{
$this->requireVirtualTable('services');
$this->select->joinLeft(
['scg' => 'icinga_service_contactgroups'],
'scg.service_id = s.service_id',
[]
)->joinLeft(
['scgo' => 'icinga_objects'],
'scgo.object_id = scg.contactgroup_object_id AND scgo.is_active = 1 AND scgo.objecttype_id = 10',
[]
);
}
/** /**
* Join host contacts * Join host contacts
*/ */
@ -142,6 +166,28 @@ class ServicegroupQuery extends IdoQuery
); );
} }
/**
* Join host contact groups
*/
protected function joinHostcontactgroups()
{
$this->requireVirtualTable('services');
$this->select->joinLeft(
['h' => 'icinga_hosts'],
'h.host_object_id = s.host_object_id',
[]
)->joinLeft(
['hcg' => 'icinga_host_contactgroups'],
'hcg.host_id = h.host_id',
[]
)->joinLeft(
['hcgo' => 'icinga_objects'],
'hcgo.object_id = hcg.contactgroup_object_id AND hcgo.is_active = 1 AND hcgo.objecttype_id = 11',
[]
);
}
/** /**
* Join host groups * Join host groups
*/ */
@ -173,7 +219,7 @@ class ServicegroupQuery extends IdoQuery
$this->requireVirtualTable('services'); $this->requireVirtualTable('services');
// Host custom var filters work w/o any host related table. If a host table join is necessary here some day, // Host custom var filters work w/o any host related table. If a host table join is necessary here some day,
// please adjust `joinHostcontacts()` where we explicitly do this already // please adjust `joinHostcontact*()` where we explicitly do this already
} }
/** /**

View File

@ -38,9 +38,15 @@ class ServicestatusQuery extends IdoQuery
'contacts' => [ 'contacts' => [
'service_contact' => 'sco.name1' 'service_contact' => 'sco.name1'
], ],
'contactgroups' => [
'service_contactgroup' => 'scgo.name1'
],
'hostcontacts' => [ 'hostcontacts' => [
'host_contact' => 'hco.name1' 'host_contact' => 'hco.name1'
], ],
'hostcontactgroups' => [
'host_contactgroup' => 'hcgo.name1'
],
'hostgroups' => array( 'hostgroups' => array(
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci', 'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci',
@ -332,6 +338,22 @@ class ServicestatusQuery extends IdoQuery
); );
} }
/**
* Join contact groups
*/
protected function joinContactgroups()
{
$this->select->joinLeft(
['scg' => 'icinga_service_contactgroups'],
'scg.service_id = s.service_id',
[]
)->joinLeft(
['scgo' => 'icinga_objects'],
'scgo.object_id = scg.contactgroup_object_id AND scgo.is_active = 1 AND scgo.objecttype_id = 10',
[]
);
}
/** /**
* Join host contacts * Join host contacts
*/ */
@ -350,6 +372,24 @@ class ServicestatusQuery extends IdoQuery
); );
} }
/**
* Join host contact groups
*/
protected function joinHostcontactgroups()
{
$this->requireVirtualTable('hosts');
$this->select->joinLeft(
['hcg' => 'icinga_host_contactgroups'],
'hcg.host_id = h.host_id',
[]
)->joinLeft(
['hcgo' => 'icinga_objects'],
'hcgo.object_id = hcg.contactgroup_object_id AND hcgo.is_active = 1 AND hcgo.objecttype_id = 11',
[]
);
}
/** /**
* Join host groups * Join host groups
*/ */

View File

@ -58,7 +58,7 @@ class Hostgroupsummary extends DataView
{ {
return array( return array(
'instance_name', 'instance_name',
'host', 'host_alias', 'host_contact', 'host_display_name', 'host_name', 'host', 'host_alias', 'host_contact', 'host_contactgroup', 'host_display_name', 'host_name',
'hostgroup', 'hostgroup',
'service', 'service_description', 'service_display_name', 'service', 'service_description', 'service_display_name',
'servicegroup', 'servicegroup_alias', 'servicegroup_name' 'servicegroup', 'servicegroup_alias', 'servicegroup_name'

View File

@ -71,7 +71,7 @@ class HostStatus extends DataView
public function getStaticFilterColumns() public function getStaticFilterColumns()
{ {
return array( return array(
'host', 'host_contact', 'host', 'host_contact', 'host_contactgroup',
'hostgroup', 'hostgroup_alias', 'hostgroup_name', 'hostgroup', 'hostgroup_alias', 'hostgroup_name',
'service', 'service_description', 'service_display_name', 'service', 'service_description', 'service_display_name',
'servicegroup', 'servicegroup_alias', 'servicegroup_name' 'servicegroup', 'servicegroup_alias', 'servicegroup_name'

View File

@ -52,9 +52,9 @@ class Servicegroupsummary extends DataView
return array( return array(
'instance_name', 'instance_name',
'services_severity', 'services_severity',
'host', 'host_alias', 'host_contact', 'host_display_name', 'host_name', 'host', 'host_alias', 'host_contact', 'host_contactgroup', 'host_display_name', 'host_name',
'hostgroup', 'hostgroup_alias', 'hostgroup_name', 'hostgroup', 'hostgroup_alias', 'hostgroup_name',
'service', 'service_contact', 'service_description', 'service_display_name', 'service', 'service_contact', 'service_contactgroup', 'service_description', 'service_display_name',
'servicegroup' 'servicegroup'
); );
} }

View File

@ -156,11 +156,13 @@ class ServiceStatus extends DataView
return array( return array(
'host', 'host',
'host_contact', 'host_contact',
'host_contactgroup',
'hostgroup', 'hostgroup',
'hostgroup_alias', 'hostgroup_alias',
'hostgroup_name', 'hostgroup_name',
'service', 'service',
'service_contact', 'service_contact',
'service_contactgroup',
'service_host', 'service_host',
'servicegroup', 'servicegroup',
'servicegroup_alias', 'servicegroup_alias',