[icinga-checkins] icinga.org: icinga2/next: Fix columns not fetched when using stats output.

git at icinga.org git at icinga.org
Thu Nov 7 17:56:02 CET 2013


Module: icinga2
Branch: next
Commit: 46548d8e56843ed8d42ef6f96179129eda61ec1d
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=46548d8e56843ed8d42ef6f96179129eda61ec1d

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Thu Nov  7 17:53:55 2013 +0100

Fix columns not fetched when using stats output.

Fixes #5015

---

 components/livestatus/query.cpp |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/components/livestatus/query.cpp b/components/livestatus/query.cpp
index c768d22..f655a85 100644
--- a/components/livestatus/query.cpp
+++ b/components/livestatus/query.cpp
@@ -428,8 +428,9 @@ void Query::ExecuteGetHelper(const Stream::Ptr& stream)
 		}
 	} else {
 		std::vector<double> stats(m_Aggregators.size(), 0);
-
 		int index = 0;
+
+		/* add aggregated stats */
 		BOOST_FOREACH(const Aggregator::Ptr aggregator, m_Aggregators) {
 			BOOST_FOREACH(const Value& object, objects) {
 				aggregator->Apply(table, object);
@@ -440,6 +441,17 @@ void Query::ExecuteGetHelper(const Stream::Ptr& stream)
 		}
 
 		Array::Ptr row = make_shared<Array>();
+
+		/*
+		 * add columns selected next to stats
+		 * may not be accurate for grouping!
+		 */
+		BOOST_FOREACH(const String& columnName, columns) {
+			Column column = table->GetColumn(columnName);
+
+			row->Add(column.ExtractValue(objects[0])); // first object wins
+		}
+
 		for (size_t i = 0; i < m_Aggregators.size(); i++)
 			row->Add(stats[i]);
 





More information about the icinga-checkins mailing list