prometheus-node-exporter-lua: handle empty lines in all_sta output correctly
authorMartin Weinelt <hexa@darmstadt.ccc.de>
Thu, 24 Jun 2021 15:50:01 +0000 (17:50 +0200)
committerEtienne Champetier <champetier.etienne@gmail.com>
Tue, 6 Jul 2021 17:37:36 +0000 (13:37 -0400)
An empty line has a name and value that is nil and setting a table
index to nil breaks metrics for every vif after the first one.

Signed-off-by: Martin Weinelt <hexa@darmstadt.ccc.de>
utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_stations.lua

index 9c56e586cfd10e08bd7fe19a19f597cd5575e43a..39d1415cc8b9c0895815ddf5aebf092be2aa0e3c 100644 (file)
@@ -129,7 +129,9 @@ local function scrape()
         current_station_values = {}
       else
         local name, value = string.match(line, "(.+)=(.+)")
-        current_station_values[name] = value
+        if name ~= nil then
+          current_station_values[name] = value
+        end
       end
     end
     labels.station = current_station