diff --git a/zte_exporter.py b/zte_exporter.py index 0d567df..b8733d3 100644 --- a/zte_exporter.py +++ b/zte_exporter.py @@ -75,7 +75,7 @@ class zteRouter: 'isTest': 'false', 'goformId': 'LOGIN', 'password': ztePass, - } + } r = s.post(self.referer + "goform/goform_set_cmd_process", headers=header, data=payload, verify=False) return "stok=" + r.cookies["stok"].strip('\"') @@ -83,7 +83,8 @@ 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%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" + 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_multi_ca_scell_sig_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 = { @@ -129,7 +130,7 @@ class serveInfos(BaseHTTPRequestHandler): 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 not len(gatheredJson['nr_multi_ca_scell_info']) == 0: + if gatheredJson['nr_multi_ca_scell_info']: for index, item in enumerate(gatheredJson['nr_multi_ca_scell_info'].split(";")): nrbit = item.split(",") if not len(nrbit[0]) == 0: @@ -158,17 +159,17 @@ class serveInfos(BaseHTTPRequestHandler): self.wfile.write(bytes("zte_snr{band=\"b%s\"} " % gatheredJson["lte_ca_pcell_band"], "utf-8")) self.wfile.write(bytes("%s\n\n" % gatheredJson["lte_snr"], "utf-8")) - if not len(gatheredJson['lte_multi_ca_scell_info']) == 0: + if gatheredJson['lte_multi_ca_scell_info'] and gatheredJson['lte_multi_ca_scell_sig_info']: for index, item in enumerate(gatheredJson['lte_multi_ca_scell_info'].split(";")): cabit = item.split(",") sigbits = gatheredJson['lte_multi_ca_scell_sig_info'].split(";") sigbit = sigbits[index].split(",") if not len(cabit[0]) == 0: self.wfile.write(bytes("zte_rsrq{band=\"b%s\"} " % cabit[3], "utf-8")) - self.wfile.write(bytes("%s\n" % sigbit[0], "utf-8")) + self.wfile.write(bytes("%s\n" % sigbit[1], "utf-8")) self.wfile.write(bytes("zte_rsrp{band=\"b%s\"} " % cabit[3], "utf-8")) - self.wfile.write(bytes("%s\n" % sigbit[1], "utf-8")) + self.wfile.write(bytes("%s\n" % sigbit[0], "utf-8")) self.wfile.write(bytes("zte_rssi{band=\"b%s\"} " % cabit[3], "utf-8")) self.wfile.write(bytes("%s\n" % sigbit[3], "utf-8")) @@ -197,4 +198,4 @@ if __name__ == "__main__": webServer.serve_forever() webServer.server_close() - print("Server stopped.") + print("Server stopped.") \ No newline at end of file