ctucx.git: fritzbox-exporter

[nimlang] prometheus exporter for lte fritzboxes

commit 4888bd75374ec1a58ab66f0592c3408d9bf94da1
parent f2c9a1341acaba1963616396bab1df808bc369a5
Author: Isabelle K <hi@f2k1.de>
Date: Tue, 20 Apr 2021 17:51:04 +0200

add bandwidth and cell ids
1 file changed, 12 insertions(+), 0 deletions(-)
M
src/fb_exporter.nim
|
12
++++++++++++
diff --git a/src/fb_exporter.nim b/src/fb_exporter.nim
@@ -76,6 +76,18 @@ proc prometheusResponse* (request: Request, state: JsonNode) {.async.} =
               let cell_usage = data[cell]["usage"].getInt
               res &= "fritzbox_network_usage{cell=\"" & $num & "\"} " & $(cell_usage) & " " & $(lastUpdated * 1000) & "\n"
 
+            if data[cell].hasKey("bandwidth"):
+              let bandwidth = data[cell]["bandwidth"].getInt
+              res &= "fritzbox_network_bandwidth{cell=\"" & $num & "\"} " & $(bandwidth) & " " & $(lastUpdated * 1000) & "\n"
+
+            if data[cell].hasKey("cell_id"):
+              let cell_id = fromHex[int](split(data[cell]["cell_id"].getStr, "-")[0])
+              res &= "fritzbox_network_cell_id{cell=\"" & $num & "\"} " & $(cell_id) & " " & $(lastUpdated * 1000) & "\n"
+
+            if data[cell].hasKey("physical_id"):
+              let physical_id = data[cell]["physical_id"].getInt
+              res &= "fritzbox_network_physical_id{cell=\"" & $num & "\"} " & $(physical_id) & " " & $(lastUpdated * 1000) & "\n"
+
         data.parseCell(0) 
         data.parseCell(1)