monitoring: Support filtering the service group summary by service custom variables
refs #9009
This commit is contained in:
parent
c299fb3ce9
commit
1ea7335b96
|
@ -24,24 +24,20 @@ class ServicestatussummaryQuery extends IdoQuery
|
|||
'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci',
|
||||
'hostgroup_name' => 'hgo.name1'
|
||||
),
|
||||
'hosts' => array(
|
||||
'host' => 'so.name1 COLLATE latin1_general_ci',
|
||||
'host_alias' => 'h.alias COLLATE latin1_general_ci',
|
||||
'host_display_name' => 'h.display_name COLLATE latin1_general_ci',
|
||||
'host_name' => 'so.name1'
|
||||
),
|
||||
'servicegroups' => array(
|
||||
'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci',
|
||||
'servicegroup_name' => 'sgo.name1',
|
||||
'servicegroup_alias' => 'sg.alias COLLATE latin1_general_ci'
|
||||
),
|
||||
'services' => array(
|
||||
'service_display_name' => 's.display_name COLLATE latin1_general_ci'
|
||||
),
|
||||
'servicestatussummary' => array(
|
||||
'host' => 'so.name1 COLLATE latin1_general_ci',
|
||||
'host_alias' => 'h.alias COLLATE latin1_general_ci',
|
||||
'host_display_name' => 'h.display_name COLLATE latin1_general_ci',
|
||||
'host_name' => 'so.name1',
|
||||
'object_type' => '(\'service\')',
|
||||
'service' => 'so.name2 COLLATE latin1_general_ci',
|
||||
'service_description' => 'so.name2',
|
||||
'service_display_name' => 's.display_name COLLATE latin1_general_ci',
|
||||
'service_host' => 'so.name1 COLLATE latin1_general_ci',
|
||||
'service_host_name' => 'so.name1',
|
||||
'services_critical' => 'SUM(CASE WHEN ss.has_been_checked != 1 THEN 0 ELSE CASE WHEN ss.current_state = 2 THEN 1 ELSE 0 END END)',
|
||||
|
@ -75,10 +71,18 @@ class ServicestatussummaryQuery extends IdoQuery
|
|||
$this->select->from(
|
||||
array('so' => $this->prefix . 'objects'),
|
||||
array()
|
||||
)->join(
|
||||
array('s' => $this->prefix . 'services'),
|
||||
's.service_object_id = so.object_id',
|
||||
array()
|
||||
)->join(
|
||||
array('ss' => $this->prefix . 'servicestatus'),
|
||||
'ss.service_object_id = so.object_id',
|
||||
array()
|
||||
)->join(
|
||||
array('h' => $this->prefix . 'hosts'),
|
||||
'h.host_object_id = s.host_object_id',
|
||||
array()
|
||||
)->where(
|
||||
'so.is_active = ?',
|
||||
1
|
||||
|
@ -87,6 +91,8 @@ class ServicestatussummaryQuery extends IdoQuery
|
|||
2
|
||||
);
|
||||
$this->joinedVirtualTables['servicestatussummary'] = true;
|
||||
// Provide table services for custom var joins
|
||||
$this->joinedVirtualTables['services'] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,7 +100,6 @@ class ServicestatussummaryQuery extends IdoQuery
|
|||
*/
|
||||
protected function joinHostgroups()
|
||||
{
|
||||
$this->requireVirtualTable('services');
|
||||
$this->select->join(
|
||||
array('hgm' => $this->prefix . 'hostgroup_members'),
|
||||
'hgm.host_object_id = s.host_object_id',
|
||||
|
@ -116,20 +121,6 @@ class ServicestatussummaryQuery extends IdoQuery
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join hosts
|
||||
*/
|
||||
protected function joinHosts()
|
||||
{
|
||||
$this->requireVirtualTable('services');
|
||||
$this->select->join(
|
||||
array('h' => $this->prefix . 'hosts'),
|
||||
'h.host_object_id = s.host_object_id',
|
||||
array()
|
||||
);
|
||||
// TODO(el): Join host objects for is_active check?
|
||||
}
|
||||
|
||||
/**
|
||||
* Join host status
|
||||
*/
|
||||
|
@ -138,10 +129,9 @@ class ServicestatussummaryQuery extends IdoQuery
|
|||
$this->requireVirtualTable('services');
|
||||
$this->select->join(
|
||||
array('hs' => $this->prefix . 'hoststatus'),
|
||||
'hs.host_object_id = s.host_object_id',
|
||||
'hs.host_object_id = so.object_id',
|
||||
array()
|
||||
);
|
||||
// TODO(el): Join host objects for is_active check?
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,16 +161,4 @@ class ServicestatussummaryQuery extends IdoQuery
|
|||
)
|
||||
->group('sgo.name1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Join services
|
||||
*/
|
||||
protected function joinServices()
|
||||
{
|
||||
$this->select->join(
|
||||
array('s' => $this->prefix . 'services'),
|
||||
's.service_object_id = so.object_id',
|
||||
array()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue