From 77140e85bd22081dd865f60a1f4acea949c54315 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Wed, 8 Nov 2023 15:15:52 +0100 Subject: [PATCH] prometheus-node-exporter-ucode: fix sporadic wifi errors and warnings 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 --- utils/prometheus-node-exporter-ucode/Makefile | 2 +- utils/prometheus-node-exporter-ucode/files/extra/wifi.uc | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/utils/prometheus-node-exporter-ucode/Makefile b/utils/prometheus-node-exporter-ucode/Makefile index 3d712c10a3..6a626d9f47 100644 --- a/utils/prometheus-node-exporter-ucode/Makefile +++ b/utils/prometheus-node-exporter-ucode/Makefile @@ -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 diff --git a/utils/prometheus-node-exporter-ucode/files/extra/wifi.uc b/utils/prometheus-node-exporter-ucode/files/extra/wifi.uc index f5f58ef687..fb46b55091 100644 --- a/utils/prometheus-node-exporter-ucode/files/extra/wifi.uc +++ b/utils/prometheus-node-exporter-ucode/files/extra/wifi.uc @@ -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"]); } } }