ctucx.git: fritzbox-exporter

prometheus exporter for lte fritzboxes [used @ fbexporter.ctu.cx]

commit bd3a22c9eaec3d27df7f9790b2a851726050c086
parent eea9c753ea7434af8eccb0497625627dd551fb7f
Author: Isabelle K <hi@f2k1.de>
Date: Sat, 8 Aug 2020 22:15:52 +0200

fix cell_technology
1 file changed, 8 insertions(+), 3 deletions(-)
M
src/fb_exporter.nim
|
11
++++++++---
diff --git a/src/fb_exporter.nim b/src/fb_exporter.nim
@@ -121,9 +121,14 @@ proc prometheusResponse* (request: Request, state: JsonNode) {.async.} =
             let cell = "cell"&cells[num]
 
             if cell != "":
-              if data[cell].hasKey("technology"):
-                let cell_technology = data[cell]["technology"].getStr
-                res &= "fritzbox_cell_techology{cell=\"" & $num & "\"} " & $(cell_technology) & " " & $(lastUpdated * 1000) & "\n"
+              if data[cell].hasKey("cell_type"):
+                let cell_technology = data[cell]["cell_type"].getStr
+                let tech_id = %* {
+                  "umts": 3,
+                  "lte":  4
+                }
+
+                res &= "fritzbox_cell_techology{cell=\"" & $num & "\"} " & $(tech_id[cell_technology].getInt) & " " & $(lastUpdated * 1000) & "\n"
 
               if data[cell].hasKey("quality"):
                 let cell_quality = data[cell]["quality"].getInt