From 30943f2a6b0e853ad9c604b10f0fdc221655b682 Mon Sep 17 00:00:00 2001 From: Dirk Heilig Date: Mon, 23 Sep 2024 13:58:31 +0200 Subject: [PATCH] add debug --- mqtt2prom/run | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mqtt2prom/run b/mqtt2prom/run index c5b8e93..d26acd8 100755 --- a/mqtt2prom/run +++ b/mqtt2prom/run @@ -64,12 +64,28 @@ $mqtt->onMessage(function ($message) use ( &$news, &$globalCounter, &$isRunning, + $mqtt, $mqttTopic ) { if ($mqttTopic . "/restart" === $message->topic) { $isRunning = false; return; } + if ($mqttTopic . "/debug" === $message->topic) { + $mqtt->publish( + $mqttTopic . "/debug", + strval( + json_encode( + $data, + JSON_UNESCAPED_SLASHES + + JSON_UNESCAPED_UNICODE + + JSON_PRETTY_PRINT + ) + ), + 2 + ); + return; + } $globalCounter++; $stats["messages"][] = time();