From f47bc466547e5bfe5d7b666e4af68292da4f16fc Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 1 Sep 2014 09:53:17 +0200 Subject: [PATCH] GroupSummary/Postgres: Fix group by in initial join query refs #5896 --- .../Monitoring/Backend/Ido/Query/GroupsummaryQuery.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 914441d03..3b7fdaa06 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; +use Icinga\Logger\Logger; use Zend_Db_Select; class GroupSummaryQuery extends IdoQuery @@ -69,8 +70,15 @@ class GroupSummaryQuery extends IdoQuery ) ); + $groupColumn = 'hostgroup'; + + if (in_array('servicegroup', $this->desiredColumns)) { + $groupColumn = 'servicegroup'; + } + $union = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL); - $this->select->from(array('statussummary' => $union), '*')->group($columns[0]); + $this->select->from(array('statussummary' => $union), array($groupColumn))->group(array($groupColumn)); + $this->joinedVirtualTables = array( 'servicestatussummary' => true, 'hoststatussummary' => true