prometheus-node-exporter-ucode: fix sporadic wifi errors and warnings
authorAndre Heider <a.heider@gmail.com>
Wed, 8 Nov 2023 14:15:52 +0000 (15:15 +0100)
committerAndre Heider <a.heider@gmail.com>
Wed, 7 Feb 2024 13:17:17 +0000 (14:17 +0100)
Some properties may not yet be available, properly guard them.

Fixes error like:
daemon.err uhttpd[2116]: error running collector 'wifi':
daemon.err uhttpd[2116]: left-hand side expression is null

Signed-off-by: Andre Heider <a.heider@gmail.com>
utils/prometheus-node-exporter-ucode/Makefile
utils/prometheus-node-exporter-ucode/files/extra/wifi.uc

index 3d712c10a366c961235a1588ca49e2c7e3cfb6fd..6a626d9f47e6c7ec0658b0940f33cfe95885991f 100644 (file)
@@ -3,7 +3,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=prometheus-node-exporter-ucode
-PKG_VERSION:=2022.12.02
+PKG_VERSION:=2024.02.07
 PKG_RELEASE:=1
 
 PKG_MAINTAINER:=Andre Heider <a.heider@gmail.com>
index f5f58ef6872d9856b95b8de94a3c873742a2b6a3..fb46b5509168e93976c50ce691f4c7a7b9548ea0 100644 (file)
@@ -110,9 +110,12 @@ for (let radio in x) {
                        m_station_rx_packets(labels, info["rx_packets"]);
                        m_station_tx_packets(labels, info["tx_packets"]);
                        m_station_signal(labels, info["signal"]);
-                       m_station_rx_bitrate(labels, info["rx_bitrate"]["bitrate32"] * 100);
-                       m_station_tx_bitrate(labels, info["tx_bitrate"]["bitrate32"] * 100);
-                       m_station_exp_tp(labels, info["expected_throughput"]);
+                       if (info["rx_bitrate"] && info["rx_bitrate"]["bitrate32"])
+                               m_station_rx_bitrate(labels, info["rx_bitrate"]["bitrate32"] * 100);
+                       if (info["tx_bitrate"] && info["tx_bitrate"]["bitrate32"])
+                               m_station_tx_bitrate(labels, info["tx_bitrate"]["bitrate32"] * 100);
+                       if (info["expected_throughput"])
+                               m_station_exp_tp(labels, info["expected_throughput"]);
                }
        }
 }