From 7daccd9efdfc7c25e65b91ad66f25d0f4a1942a9 Mon Sep 17 00:00:00 2001 From: agessaman Date: Tue, 21 Jul 2026 08:42:25 -0700 Subject: [PATCH] feat(mqtt): include outbox drop statistics in MQTT stats reply Enhance the MQTT stats reply to include outbox drop statistics, providing users with better insight into message handling and memory pressure. This change improves the clarity of the status message and aids in diagnosing potential issues with message delivery. --- src/helpers/bridges/MQTTBridge.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/helpers/bridges/MQTTBridge.cpp b/src/helpers/bridges/MQTTBridge.cpp index d375cb510..4102cbe5c 100644 --- a/src/helpers/bridges/MQTTBridge.cpp +++ b/src/helpers/bridges/MQTTBridge.cpp @@ -320,14 +320,20 @@ void MQTTBridge::formatMqttStatsReply(char* buf, size_t bufsize) { #endif size_t outbox_total = 0; + unsigned long outbox_drops = 0; for (int i = 0; i < RUNTIME_MQTT_SLOTS; i++) { - if (b->_slots[i].client) outbox_total += b->_slots[i].client->getOutboxSize(); + if (b->_slots[i].client) { + outbox_total += b->_slots[i].client->getOutboxSize(); + outbox_drops += b->_slots[i].client->getOutboxDrops(); + } } + // drops=/: outbox-cap drops vs. memory-pressure skips. int pos = 0; - replyAppendf(buf, bufsize, &pos, "> Free=%d Max=%d q:%d/%d Outbox=%u |", + replyAppendf(buf, bufsize, &pos, "> Free=%d Max=%d q:%d/%d Outbox=%u drops=%lu/%d |", (int)ESP.getFreeHeap(), (int)ESP.getMaxAllocHeap(), - q, MAX_QUEUE_SIZE, (unsigned)outbox_total); + q, MAX_QUEUE_SIZE, (unsigned)outbox_total, + outbox_drops, b->_skipped_publishes); for (int i = 0; i < RUNTIME_MQTT_SLOTS; i++) { if (!b->_slots[i].enabled || !b->_slots[i].client) continue; replyAppendf(buf, bufsize, &pos, " s%d=%lu/%lu", i + 1,