From aeb0b7bcee9e8e4e41da881ef65bb2c62c65c39b Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 23 Jun 2021 13:48:05 -0400 Subject: [PATCH] TT#14008 fix MQTT global stats The JSON context is already in an object, therefore skip the surrounding {} enclosure. Also don't run the global MQTT timer when MQTT is disabled. closes #1290 Change-Id: I63c622bd339545e625ee18def33f21de2533f949 --- daemon/call.c | 3 ++- daemon/mqtt.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/daemon/call.c b/daemon/call.c index f4be027d9..7480dcd42 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -725,7 +725,8 @@ int call_init() { poller_add_timer(rtpe_poller, call_timer, NULL); - mqtt_timer_start(&global_mqtt_timer, NULL, NULL); + if (mqtt_publish_scope() != MPS_NONE) + mqtt_timer_start(&global_mqtt_timer, NULL, NULL); return 0; } diff --git a/daemon/mqtt.c b/daemon/mqtt.c index 9ebbe85f0..75effb9f3 100644 --- a/daemon/mqtt.c +++ b/daemon/mqtt.c @@ -388,6 +388,12 @@ static void mqtt_global_stats(JsonBuilder *json) { if (!m->label) continue; + if (m->is_bracket && l == metrics->head) // skip initial { + continue; + if (m->is_bracket && l == metrics->tail) // skip final } + continue; + + if (m->value_short) { json_builder_set_member_name(json, m->label); if (m->is_int)