Module: check_mk
Branch: master
Commit: b98f45166023e538dda70300b68909b8273809bd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b98f45166023e5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 28 09:55:39 2015 +0200
#2493 FIX Fixed wrong JSON format when using stats queries together with header columns
e.g. this query lead to invalid JSON output:
GET statehist
Filter: time >= 1425168000
Filter: time < 1427846400
Filter: host_name = name
Filter: service_description = Description
Stats: sum duration_part_ok
OutputFormat: json
ColumnHeaders: on
Output:
[["stats_1"][0.0000000000e+00]]
---
.werks/2493 | 22 ++++++++++++++++++++++
ChangeLog | 3 +++
livestatus/src/Query.cc | 5 +++++
3 files changed, 30 insertions(+)
diff --git a/.werks/2493 b/.werks/2493
new file mode 100644
index 0000000..3dc6eab
--- /dev/null
+++ b/.werks/2493
@@ -0,0 +1,22 @@
+Title: Fixed wrong JSON format when using stats queries together with header columns
+Level: 1
+Component: livestatus
+Compatible: compat
+Version: 1.2.7i3
+Date: 1438069896
+Class: fix
+
+e.g. this query lead to invalid JSON output:
+
+GET statehist
+Filter: time >= 1425168000
+Filter: time < 1427846400
+Filter: host_name = name
+Filter: service_description = Description
+Stats: sum duration_part_ok
+OutputFormat: json
+ColumnHeaders: on
+
+Output:
+[["stats_1"][0.0000000000e+00]]
+
diff --git a/ChangeLog b/ChangeLog
index ae5df7e..1901761 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -142,6 +142,9 @@
* 2322 FIX: mkeventd: MIBs are now only loaded if SNMP Traps translation is
activated...
* 2460 FIX: Slightly more robust SNMP trap translation...
+ Livestatus:
+ * 2493 FIX: Fixed wrong JSON format when using stats queries together with header
columns...
+
HW/SW-Inventory:
* 2128 mk_inventory.vbs: inventory plugin for Windows now available as vbs script...
* 2367 FIX: win_system: Fixed exception when non-UTF-8 sequences are contained agent
output
diff --git a/livestatus/src/Query.cc b/livestatus/src/Query.cc
index 8bb3b93..876cb5a 100644
--- a/livestatus/src/Query.cc
+++ b/livestatus/src/Query.cc
@@ -963,6 +963,11 @@ void Query::finish()
// stats without group column
else if (doStats()) {
+ if (_need_ds_separator && _output_format != OUTPUT_FORMAT_CSV)
+ _output->addBuffer(",\n", 2);
+ else
+ _need_ds_separator = true;
+
outputDatasetBegin();
for (unsigned i=0; i<_stats_columns.size(); i++)
{