From 37103cf72d1674798db51ba254650ef150bfe2ce Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 18 Jun 2015 11:52:58 +0200 Subject: [PATCH] HoststatusQuery: PostgreSQL grouping... refs #9009 --- .../Backend/Ido/Query/HoststatusQuery.php | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index f3c3bef44..30adf696f 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -230,7 +230,6 @@ SQL; 'hgo.object_id = hg.hostgroup_object_id AND hgo.is_active = 1 AND hgo.objecttype_id = 3', array() ); - $this->group('ho.name1'); } /** @@ -312,7 +311,6 @@ SQL; 'sgo.object_id = sg.servicegroup_object_id AND sgo.is_active = 1 AND sgo.objecttype_id = 4', array() ); - $this->group('ho.name1'); } /** @@ -330,7 +328,6 @@ SQL; 'so.object_id = s.service_object_id AND so.is_active = 1 AND so.objecttype_id = 2', array() ); - $this->group('ho.name1'); } /** @@ -371,4 +368,40 @@ SQL; array() ); } + + /** + * {@inheritdoc} + */ + public function getGroup() + { + $group = array(); + if ($this->hasJoinedVirtualTable('hostgroups') || $this->hasJoinedVirtualTable('services')) { + $group = array('h.host_id', 'ho.object_id'); + if ($this->hasJoinedVirtualTable('hoststatus')) { + $group[] = 'hs.hoststatus_id'; + } + + if ($this->hasJoinedVirtualTable('serviceproblemsummary')) { + $group[] = 'sps.unhandled_services_count'; + } + + if ($this->hasJoinedVirtualTable('lasthostackcomment')) { + $group[] = 'hlac.last_ack_data'; + } + + if ($this->hasJoinedVirtualTable('lasthostcomment')) { + $group[] = 'hlc.last_comment_data'; + } + + if ($this->hasJoinedVirtualTable('lasthostdowntimecomment')) { + $group[] = 'hldc.last_downtime_data'; + } + + if ($this->hasJoinedVirtualTable('lasthostflappingcomment')) { + $group[] = 'hlfc.last_flapping_data'; + } + } + + return $group; + } }