From c455a5eb6bd4e47fe33e7036b9331deaaf255791 Mon Sep 17 00:00:00 2001 From: VG Date: Sun, 8 Dec 2024 09:09:23 +0200 Subject: [PATCH] fix whitespaces, clean up, add minor network info --- zte_exporter.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/zte_exporter.py b/zte_exporter.py index 81acb83..d6fcb5a 100644 --- a/zte_exporter.py +++ b/zte_exporter.py @@ -83,7 +83,7 @@ class zteRouter: def zteinfo(self): ip = self.ip cookie = self.getCookie(username=self.username, password=self.password, LD=self.get_LD(), login=self.login) - cmd_url = f"{self.protocol}://{self.ip}/goform/goform_get_cmd_process?multi_data=1&isTest=false&cmd=wa_inner_version%2Cwan_ipaddr%2Cwan_apn%2Ccell_id%2Cnr5g_action_band%2CZ5g_rsrq%2CZ5g_rsrp%2CZ5g_rssi%2CZ5g_SINR%2Cnr_multi_ca_scell_info%2Clte_multi_ca_scell_info%2Clte_ca_pcell_band%2Clte_rsrp%2Clte_rsrq%2Clte_rssi%2Clte_snr%2Cmonthly_tx_bytes%2Cmonthly_rx_bytes%2Crealtime_tx_bytes%2Crealtime_rx_bytes%2Crealtime_tx_thrpt%2Crealtime_rx_thrpt"%2Cnr_multi_ca_scell_info%2Cnr5g_action_band" + cmd_url = f"{self.protocol}://{self.ip}/goform/goform_get_cmd_process?multi_data=1&isTest=false&cmd=wa_inner_version%2Cwan_ipaddr%2Cwan_apn%2Cnetwork_type%2Cnr5g_action_band%2CZ5g_rsrq%2CZ5g_rsrp%2CZ5g_rssi%2CZ5g_SINR%2Cnr_multi_ca_scell_info%2Clte_multi_ca_scell_info%2Clte_ca_pcell_band%2Clte_rsrp%2Clte_rsrq%2Clte_rssi%2Clte_snr%2Cmonthly_tx_bytes%2Cmonthly_rx_bytes%2Crealtime_tx_bytes%2Crealtime_rx_bytes%2Crealtime_tx_thrpt%2Crealtime_rx_thrpt%2Cnr_multi_ca_scell_info%2Cnr5g_action_band" cookie_pass = cookie headers = { @@ -94,11 +94,11 @@ class zteRouter: response = s.get(cmd_url, headers=headers, verify=False) return response.text - + def iterateCellInfo(self, str, type): for f in str: print (f) - + zteInstance = zteRouter(args.ip, args.username, args.password, args.login) serverPort = args.port @@ -111,10 +111,10 @@ class serveInfos(BaseHTTPRequestHandler): self.end_headers() self.wfile.write(bytes("# HELP zte_modem_info Modem general information\n# TYPE zte_modem_info untyped\n", "utf-8")) - self.wfile.write(bytes("zte_modem_info{firmware=\"%s\",ip_addr=\"" % gatheredJson["wa_inner_version"], "utf-8")) - self.wfile.write(bytes("%s\",apn=\"" % gatheredJson["wan_ipaddr"], "utf-8")) - self.wfile.write(bytes("%s\",cell_id=\"" % gatheredJson["wan_apn"], "utf-8")) - self.wfile.write(bytes("%s\"} 1\n\n" % gatheredJson["cell_id"], "utf-8")) + self.wfile.write(bytes("zte_modem_info{firmware=\"%s\"," % gatheredJson["wa_inner_version"], "utf-8")) + self.wfile.write(bytes("ip_addr=\"%s\"," % gatheredJson["wan_ipaddr"], "utf-8")) + self.wfile.write(bytes("apn=\"%s\"," % gatheredJson["wan_apn"], "utf-8")) + self.wfile.write(bytes("network_type=\"%s\"} 1\n\n" % gatheredJson["network_type"], "utf-8")) self.wfile.write(bytes("# HELP zte_rsrp Reference Signal Received Power\n# TYPE zte_rsrp gauge\n", "utf-8")) self.wfile.write(bytes("# HELP zte_snr Signal-to-Interference-plus-Noise Ratio\n# TYPE zte_snr gauge\n", "utf-8")) @@ -127,13 +127,13 @@ class serveInfos(BaseHTTPRequestHandler): self.wfile.write(bytes("zte_rsrp{band=\"%s\"} " % gatheredJson["nr5g_action_band"], "utf-8")) self.wfile.write(bytes("%s\n" % gatheredJson["Z5g_rsrp"], "utf-8")) - + self.wfile.write(bytes("zte_rssi{band=\"%s\"} " % gatheredJson["nr5g_action_band"], "utf-8")) self.wfile.write(bytes("%s\n" % gatheredJson["Z5g_rssi"], "utf-8")) self.wfile.write(bytes("zte_snr{band=\"%s\"} " % gatheredJson["nr5g_action_band"], "utf-8")) self.wfile.write(bytes("%s\n\n" % gatheredJson["Z5g_SINR"], "utf-8")) - + if gatheredJson['nr_multi_ca_scell_info']: for index, item in enumerate(gatheredJson['nr_multi_ca_scell_info'].split(";")): nrbit = item.split(",") @@ -156,7 +156,7 @@ class serveInfos(BaseHTTPRequestHandler): self.wfile.write(bytes("zte_rsrp{band=\"%s\"} " % gatheredJson["lte_ca_pcell_band"], "utf-8")) self.wfile.write(bytes("%s\n" % gatheredJson["lte_rsrp"], "utf-8")) - + self.wfile.write(bytes("zte_rssi{band=\"%s\"} " % gatheredJson["lte_ca_pcell_band"], "utf-8")) self.wfile.write(bytes("%s\n" % gatheredJson["lte_rssi"], "utf-8"))