fixes for logics

main
"Riku" 2025-01-21 13:00:36 +02:00
parent 4596e0dddb
commit 00b4497375
1 changed files with 7 additions and 8 deletions

View File

@ -14,7 +14,7 @@ import argparse
parser = argparse.ArgumentParser("ZTE simple exporter")
parser.add_argument("ip", help="Router ip address")
parser.add_argument("username", help="Router username", default="admin")
parser.add_argument("--username", help="Router username", default="admin")
parser.add_argument("password", help="Router password")
parser.add_argument("--port", help="Serve metrics on what port", type=int, default=8999)
parser.add_argument("--reset", help="Reset tr069 info", default=False, type=bool)
@ -27,8 +27,7 @@ s = requests.Session()
class zteRouter:
def __init__(self, ip, username, password, login, device):
self.login = login
def __init__(self, ip, username, password, device):
self.ip = ip
self.protocol = "http" # default to http
self.username = username
@ -129,7 +128,7 @@ class zteRouter:
def resettr69(self):
ip = self.ip
cookie = self.getCookie(username=self.username, password=self.password, LD=self.get_LD(), login=self.device)
cookie = self.getCookie(username=self.username, password=self.password, LD=self.get_LD(), device=self.device)
cmd_url = f"{self.protocol}://{self.ip}/goform/goform_get_cmd_process?multi_data=1&isTest=false&cmd=cr_version%2Ctr069_ServerURL%2Ctr069_CPEPortNo%2Ctr069_ServerUsername%2Ctr069_ServerPassword%2Ctr069_ConnectionRequestUname%2Ctr069_ConnectionRequestPassword%2Cwan_ipaddr%2Ctr069_PeriodicInformEnable%2Ctr069_PeriodicInformInterval%2Ctr069_CertEnable%2Ctr069_DataModule%2Ctr069_Webui_DataModuleSupport"
headers = {
@ -144,7 +143,7 @@ class zteRouter:
print("\n---")
ip = self.ip
cookie = self.getCookie(username=self.username, password=self.password, LD=self.get_LD(), login=self.device)
cookie = self.getCookie(username=self.username, password=self.password, LD=self.get_LD(), device=self.device)
headers = {
"Host": ip,
@ -178,7 +177,7 @@ class zteRouter:
def zteinfo(self):
ip = self.ip
cookie = self.getCookie(username=self.username, password=self.password, LD=self.get_LD(), login=self.device)
cookie = self.getCookie(username=self.username, password=self.password, LD=self.get_LD(), device=self.device)
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"
headers = {
@ -190,7 +189,7 @@ class zteRouter:
response = s.get(cmd_url, headers=headers, verify=False, timeout=1)
return response.text
zteInstance = zteRouter(args.ip, args.username, args.password, args.login, args.device)
zteInstance = zteRouter(args.ip, args.username, args.password, args.device)
serverPort = args.port
class serveInfos(BaseHTTPRequestHandler):
@ -301,4 +300,4 @@ if __name__ == "__main__":
webServer.serve_forever()
webServer.server_close()
print("Server stopped.")
print("Server stopped.")