From e0a46601b7652d181f0c503109740b8795727f28 Mon Sep 17 00:00:00 2001 From: jaydee Date: Fri, 17 Feb 2023 16:40:15 +0100 Subject: [PATCH] asa --- mqtt_srv.py | 280 +++++++++++++++++++++++++++------------------------- 1 file changed, 143 insertions(+), 137 deletions(-) diff --git a/mqtt_srv.py b/mqtt_srv.py index cfb8d4c..08ea380 100644 --- a/mqtt_srv.py +++ b/mqtt_srv.py @@ -20,51 +20,57 @@ import requests #import psutil stats = {} VERSION = "1.0.23" -curos = platform.system() +curos = platform.system() host = platform.node().lower() print(host) if curos == "Windows": import winreg def uptime(): - - try: - f = open( "/proc/uptime" ) - contents = f.read().split() - f.close() - except: + + try: + f = open( "/proc/uptime" ) + contents = f.read().split() + f.close() + except: return "Cannot open uptime file: /proc/uptime" - - total_seconds = float(contents[0]) - - # Helper vars: - MINUTE = 60 - HOUR = MINUTE * 60 - DAY = HOUR * 24 - - # Get the days, hours, etc: - days = int( total_seconds / DAY ) - hours = int( ( total_seconds % DAY ) / HOUR ) - minutes = int( ( total_seconds % HOUR ) / MINUTE ) - seconds = int( total_seconds % MINUTE ) - + + total_seconds = float(contents[0]) + + # Helper vars: + MINUTE = 60 + HOUR = MINUTE * 60 + DAY = HOUR * 24 + + # Get the days, hours, etc: + days = int( total_seconds / DAY ) + hours = int( ( total_seconds % DAY ) / HOUR ) + minutes = int( ( total_seconds % HOUR ) / MINUTE ) + seconds = int( total_seconds % MINUTE ) + # Build up the pretty string (like this: "N days, N hours, N minutes, N seconds") - string = "" + string = "" # if days > 0: # string += str(days) + " " + (days == 1 and "d" or "d" ) + ", " # if len(string) > 0 or hours > 0: # string += str(hours) + " " + (hours == 1 and "h" or "h" ) + ", " # if len(string) > 0 or minutes > 0: # string += str(minutes) + " " + (minutes == 1 and "m" or "m" ) + ", " - if days > 0: - string += str(days) + " " + (days == 1 and "d" or "d" ) + ", " - if len(string) > 0 or hours > 0: - string += str(hours) + ":" - if len(string) > 0 or minutes > 0: - string += str(minutes) + ":" - string += str(seconds) - - return string; - + if days > 0: + string += str(days) + " " + (days == 1 and "d" or "d" ) + ", " + if len(string) > 0 or hours > 0: + if hours < 10: + hours = "0{}".format(hours) + string += str(hours) + ":" + if len(string) > 0 or minutes > 0: + if minutes < 10: + minutes = "0{}".format(minutes) + string += str(minutes) + ":" + + if seconds < 10: + seconds = "0{}".format(seconds) + string += str(seconds) + return string; + def writeLog(msg, svr="INFO"): ts = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") if curos == "Windows": @@ -73,14 +79,14 @@ def writeLog(msg, svr="INFO"): log_path = "/tmp/mqtt_srv.log" f = open(log_path, "a") f.write(ts + " | " + svr + " | " + str(msg) + "\n") - f.close() + f.close() def check_router(): stats["uptime"] = uptime() stats["version"] = VERSION cmnd = "crontab -l" status, output = subprocess.getstatusoutput(cmnd) - + if "#Skynet_banmalware#" in output: stats["skynet"] = "on" else: @@ -89,8 +95,8 @@ def check_router(): stats["diversion"] = "on" else: stats["diversion"] = "off" - - + + cmnd = "nvram get vpn_client1_state" status, output = subprocess.getstatusoutput(cmnd) writeLog("Openvpn1 Status : " + str(output)) @@ -127,11 +133,11 @@ def check_router(): #stats["serv_dest"] = json.dumps(serv_d) #out = subprocess.Popen(cmnd.split()) #status, output = subprocess.getstatusoutput(cmnd) - - + + ''' - - + + print("Getting fw info") cmnd = "/root/router_cmd.sh -t firewall -n TOSHIBA-WIFI -m get" #out = subprocess.Popen(cmnd.split()) @@ -154,10 +160,10 @@ def check_router(): #client.publish("sectorq/systems/router/stats", payload=json.dumps(stats), qos=0, retain=True) #else: # client.publish("sectorq/systems/router/macfilter", payload=0, qos=0, retain=True) - + if host != "router" and host != "nas": import psutil - + processes = list(p.name() for p in psutil.process_iter()) # print(processes) count = processes.count("mqtt_srv.exe") @@ -171,12 +177,12 @@ else: if int(count) >= 2: writeLog("script exist") sys.exit() - - + + # Stops duplicate instance from running - + writeLog(count) writeLog("Starting : " + str(VERSION)) @@ -215,7 +221,7 @@ for o, a in opts: _MESSAGE = a elif o in ("-t", "--publish"): _TOPIC = a - elif o in ("-S", "--setvar"): + elif o in ("-S", "--setvar"): _SETVAR = True _THR_NAME = sys.argv[2] _THR_VAL = sys.argv[3] @@ -319,7 +325,7 @@ IP = get_ip() print("OS : " + curos) writeLog("OS : " + curos) if curos != "Windows": - import autorandr + import autorandr else: import winreg @@ -358,14 +364,14 @@ def on_connect(client, userdata, flags, rc): client.publish("sectorq/systems/" + host.lower() + "/stat", payload="on", qos=0, retain=True) if host.lower() == "router": check_router() - + if host.lower() == "nas": print("Getting VM info") - + cmnd = "/share/ZFS530_DATA/.qpkg/QKVM/usr/bin/virsh list --all" print(cmnd) status, output = subprocess.getstatusoutput(cmnd) - l = 1 + l = 1 lines = output.splitlines() VMS = {} for i in lines: @@ -375,11 +381,11 @@ def on_connect(client, userdata, flags, rc): line = re.split(r" {2,}", i) print(str(line[0].strip()) + " " + str(line[1].strip()) + " " + str(line[2].strip())) VMS[str(line[1].strip())] = str(line[2].strip()) - - - + + + for m in VMS: - + cmnd = "/share/ZFS530_DATA/.qpkg/QKVM/usr/bin/virsh domstate " + m #out = subprocess.Popen(cmnd.split()) print(cmnd) @@ -389,7 +395,7 @@ def on_connect(client, userdata, flags, rc): client.publish("sectorq/systems/nas/" + m, payload=1, qos=0, retain=True) else: client.publish("sectorq/systems/nas/" + m, payload=0, qos=0, retain=True) - + client.subscribe(topic) @@ -417,14 +423,14 @@ def on_message(client, userdata, msg): except: print("Action not set") writeLog("Action not set", "WARNING") - + try: print(myObj["cmd"]) writeLog(myObj["cmd"]) except: print("Cmd not set") writeLog("Cmd not set", "WARNING") - + try: print(myObj["target"]) writeLog(myObj["target"]) @@ -444,7 +450,7 @@ def on_message(client, userdata, msg): except: print("Command Not Set") writeLog("Command Not Set") - + try: print(myObj["cmd_line"]) writeLog(myObj["cmd_line"]) @@ -466,7 +472,7 @@ def on_message(client, userdata, msg): ctypes.windll.user32.MessageBoxW(0, "Your text", "Your title", 16) print("Executed " + myObj["cmd_line"]) writeLog("Executed " + myObj["cmd_line"]) - + if myObj["cmd"] == "nas_cmd": print("Executing NAS") cmnd = "/share/ZFS530_DATA/.qpkg/QKVM/usr/bin/virsh domstate " + str(myObj["target"]) @@ -483,8 +489,8 @@ def on_message(client, userdata, msg): cmd_type = "start" if myObj["command"] == "suspend": cmd_type = "shutdown" - - + + cmnd = "/share/ZFS530_DATA/.qpkg/QKVM/usr/bin/virsh " + cmd_type + " " + str(myObj["target"]) subprocess.Popen(cmnd.split()) print(cmnd) @@ -502,14 +508,14 @@ def on_message(client, userdata, msg): except: print("failed to execute!") client.publish("sectorq/systems/nas/" + str(myObj["target"]), payload="failed", qos=0, retain=False) - - + + if myObj["cmd"] == "distrib": print("distributin313g") # os.startfile(sys.argv[0]) #sys.exit() subprocess.Popen(['/bin/systemctl', 'restart', 'mqtt']) - + if myObj["cmd"] == "uci": print("uci1") print("Executing " + myObj["cmd_line"]) @@ -526,7 +532,7 @@ def on_message(client, userdata, msg): except: print("failed to execute!") client.publish("sectorq/systems/router/stats", payload="failed", qos=0, retain=False) - + elif myObj["cmd_line"] == "wireless0": cmnd = "/root/router_cmd.sh -t wireless -v 0 -m set" try: @@ -566,10 +572,10 @@ def on_message(client, userdata, msg): cmnd = "service {}".format(myObj["target"]) print(cmnd) status, output = subprocess.getstatusoutput(cmnd) - + elif myObj["cmd_line"] == "serv_dest": writeLog("Payload111111 : " + myObj["target"].lower()) - + cmnd = "nvram get vts_rulelist" status, output = subprocess.getstatusoutput(cmnd) rule_data = output.split("<") @@ -597,7 +603,7 @@ def on_message(client, userdata, msg): serv_d[r]["dest_ip"] = myObj["target"] except: serv_d[r] = rules[r] - + lala = [] for sr in serv_d: lala.append("{}>{}>{}>{}>{}>".format(sr,serv_d[sr]["src_port"],serv_d[sr]["dest_ip"],serv_d[sr]["dest_port"],serv_d[sr]["prot"])) @@ -611,7 +617,7 @@ def on_message(client, userdata, msg): status, output = subprocess.getstatusoutput(cmnd) cmnd = "service restart_firewall" status, output = subprocess.getstatusoutput(cmnd) - writeLog("Payload111114") + writeLog("Payload111114") writeLog(output) print(json.dumps(serv_d)) ''' @@ -619,29 +625,29 @@ def on_message(client, userdata, msg): dest_ip = "192.168.77.246" elif myObj["target"].lower() == "192.168.77.106": dest_ip = "192.168.77.106" - - - - + + + + RULES = ["EMAIL993", "EMAIL995", "EMAIL143", "EMAIL25", "EMAIL993", "EMAIL465", "HTTPS", "HTTP"] for i in RULES: cmnd = "uci set firewall.{}.dest_ip={}".format(i,dest_ip) writeLog(cmnd) subprocess.Popen(cmnd.split()) - + #cmnd = "uci set dhcp.@dnsmasq[0].address=/mqtt_broker/" + dest_ip #writeLog(cmnd) #subprocess.Popen(cmnd.split()) time.sleep(1) cmnd = "uci commit" - + subprocess.Popen(cmnd.split()) - + writeLog("Starting " + myObj["target"].lower()) if myObj["target"].lower() == "192.168.77.246": dest_ip = "192.168.77.246" - - + + cmnd = "ssh root@192.168.77.246 'docker start mailu_resolver_1 mailu_redis_1 mailu_front_1 mailu_antispam_1 mailu_imap_1 mailu_admin_1 mailu_smtp_1 mailu_webmail_1 watchtower_watchtower_1 nginx-proxy-manager_db_1 nginx-proxy-manager_app_1 HomeAssistant webhub_client_1 dockermon_docker_mon_1 mosquitto_mosquitto_1 node-red_node-red_1 nextcloud_db_1 nextcloud_app_1'" status, output = subprocess.getstatusoutput(cmnd) elif myObj["target"].lower() == "192.168.77.106": @@ -657,7 +663,7 @@ def on_message(client, userdata, msg): MQTT_BROKER = dest_ip MQTT_USER = "jaydee" MQTT_PASS = "jaydee1" - + cmnd = "nmap -sP 192.168.77.*|grep \"Nmap scan report\"|egrep -o \"[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\"" #print(cmnd) status, output = subprocess.getstatusoutput(cmnd) @@ -674,11 +680,11 @@ def on_message(client, userdata, msg): if status == 0: try: # url = "http://" + sys_ip + "/cm?user=admin&password=l4c1j4yd33Du5l0&cmnd=STATUS+5" - + url = "http://" + sys_ip + "/cm?cmnd=Backlog%20MqttHost%20" + MQTT_BROKER + "%3BMqttUser%20" + MQTT_USER + "%3BMqttPassword%20" + MQTT_PASS print(url) requests.get(url) - + except: #print(sys_ip + " : Not a tasmota!") pass @@ -686,8 +692,8 @@ def on_message(client, userdata, msg): #print(sys_ip + " : Not a listening") pass - - + + time.sleep(1) cmnd = "sed -i 's/^MQTT_HOST = .*/MQTT_HOST = \"" + dest_ip + "\"/' /root/mqtt_srv.py" writeLog(cmnd) @@ -696,13 +702,13 @@ def on_message(client, userdata, msg): else: pass #cmnd = "/root/router_cmd.sh -t wireless -v 0" - - + + print("Executed " + cmnd) writeLog("Executed " + cmnd) ''' - - + + if myObj["cmd"] == "banip": if myObj["status"] == "ban": cmnd = "echo " + str(myObj["target"]) + " >> /etc/banip/banip.blacklist; /etc/init.d/banip refresh" @@ -714,13 +720,13 @@ def on_message(client, userdata, msg): stats["banip"] = "paused" writeLog(cmnd) status, output = subprocess.getstatusoutput(cmnd) - + client.publish("sectorq/systems/router/stats", payload=json.dumps(stats), qos=0, retain=True) - + if myObj["cmd"] == "vnc": print(myObj["target"]) writeLog(myObj["target"]) - + # os.startfile(sys.argv[0]) #sys.exit() myCmd = 'c:\\Program Files\\RealVNC\\VNC Viewer\\vncviewer.exe C:\\Users\\jaydee\\' + myObj["target"].upper() + '.vnc' @@ -737,7 +743,7 @@ def on_message(client, userdata, msg): client.publish("sectorq/monitor/" + host.lower(), payload="{\"mb_temp\":0,\"mem_usage\":0,\"cpu_temp\":0,\"cpu_usage\":0,\"gpu_temp\":0,\"gpu_usage\":0}", qos=0, retain=False) print("lalaa2") - + if myObj["cmd"] == "display": if curos == "Windows1": # os.startfile(sys.argv[0]) @@ -755,21 +761,21 @@ def on_message(client, userdata, msg): myCmd = "" if myObj["target"] == "mid": myCmd = "xrandr --output HDMI-2 --primary --auto --mode 1920x1080 --output DVI-I-2-1 --off --output HDMI-1 --off --output eDP-1 --off" - elif myObj["target"] == "all": + elif myObj["target"] == "all": myCmd = "xrandr --output HDMI-2 --primary --auto --mode 1920x1080 --output DVI-I-2-1 --auto --above HDMI-2 --mode 1920x1080 --output HDMI-1 --auto --left-of HDMI-2 --mode 1920x1080 --output eDP-1 --auto --right-of HDMI-2 --mode 1920x1080" - elif myObj["target"] == "midleft": + elif myObj["target"] == "midleft": myCmd = "xrandr --output HDMI-2 --primary --auto --mode 1920x1080 --output DVI-I-2-1 --off --output HDMI-1 --auto --left-of HDMI-2 --mode 1920x1080 --output eDP-1 --off" - elif myObj["target"] == "midtop": + elif myObj["target"] == "midtop": myCmd = "xrandr --output HDMI-2 --primary --auto --mode 1920x1080 --output DVI-I-2-1 --auto --above HDMI-2 --mode 1920x1080 --output HDMI-1 --off --output eDP-1 --off" - elif myObj["target"] == "midleftbuild": - myCmd = "xrandr --output HDMI-2 --primary --auto --mode 1920x1080 --output DVI-I-2-1 --off --output HDMI-1 --auto --left-of HDMI-2 --mode 1920x1080 --output eDP-1 --auto --right-of HDMI-2 --mode 1920x1080" - elif myObj["target"] == "midbuild": + elif myObj["target"] == "midleftbuild": + myCmd = "xrandr --output HDMI-2 --primary --auto --mode 1920x1080 --output DVI-I-2-1 --off --output HDMI-1 --auto --left-of HDMI-2 --mode 1920x1080 --output eDP-1 --auto --right-of HDMI-2 --mode 1920x1080" + elif myObj["target"] == "midbuild": myCmd = "xrandr --output HDMI-2 --primary --auto --mode 1920x1080 --output DVI-I-2-1 --off --output HDMI-1 --off --output eDP-1 --auto --right-of HDMI-2 --mode 1920x1080" - elif myObj["target"] == "midlefttop": + elif myObj["target"] == "midlefttop": myCmd = "xrandr --output HDMI-2 --primary --auto --mode 1920x1080 --output DVI-I-2-1 --auto --above HDMI-2 --mode 1920x1080 --output HDMI-1 --auto --left-of HDMI-2 --mode 1920x1080 --output eDP-1 --off" else: - pass - + pass + if myCmd != "": print(myCmd) subprocess.Popen(myCmd.split()) @@ -791,29 +797,29 @@ def on_message(client, userdata, msg): mon2 = "HDMI-2" mon3 = "DVI-I-2-1" mon4 = "eDP-1" - + if myObj["target"] == "mid": myCmd = "xrandr --output " + mon2 + " --primary --auto --mode 1920x1080 --output " + mon3 + " --off --output " +mon1 + " --off --output " + mon4 + " --off" - elif myObj["target"] == "left": - myCmd = "xrandr --output " + mon1 + " --primary --auto --mode 1920x1080 --output " + mon3 + " --off --output " +mon2 + " --off --output " + mon4 + " --off" - - elif myObj["target"] == "all": + elif myObj["target"] == "left": + myCmd = "xrandr --output " + mon1 + " --primary --auto --mode 1920x1080 --output " + mon3 + " --off --output " +mon2 + " --off --output " + mon4 + " --off" + + elif myObj["target"] == "all": myCmd = "xrandr --output " + mon2 + " --primary --auto --mode 1920x1080 --output " + mon3 + " --auto --right-of " + mon2 + " --mode 1920x1080 --output " + mon1 + " --auto --left-of " + mon2 + " --mode 1920x1080 --output " + mon4 + " --auto --right-of " + mon2 + " --mode 1920x1080" - elif myObj["target"] == "midleft": + elif myObj["target"] == "midleft": myCmd = "xrandr --output " + mon2 + " --primary --auto --mode 1920x1080 --output " + mon3 + " --off --output " + mon1 + " --auto --left-of " + mon2 + " --mode 1920x1080 --output " + mon4 + " --off" - elif myObj["target"] == "midtop": + elif myObj["target"] == "midtop": myCmd = "xrandr --output " + mon2 + " --primary --auto --mode 1920x1080 --output " + mon3 + " --auto --right-of " + mon2 + " --mode 1920x1080 --output " + mon1 + " --off --output " + mon4 + " --off" - elif myObj["target"] == "midleftbuild": - myCmd = "xrandr --output " + mon2 + " --primary --auto --mode 1920x1080 --output " + mon3 + " --off --output " + mon1 + " --auto --left-of " + mon2 + " --mode 1920x1080 --output " + mon4 + " --auto --right-of " + mon2 + " --mode 1920x1080" - elif myObj["target"] == "midbuild": + elif myObj["target"] == "midleftbuild": + myCmd = "xrandr --output " + mon2 + " --primary --auto --mode 1920x1080 --output " + mon3 + " --off --output " + mon1 + " --auto --left-of " + mon2 + " --mode 1920x1080 --output " + mon4 + " --auto --right-of " + mon2 + " --mode 1920x1080" + elif myObj["target"] == "midbuild": myCmd = "xrandr --output " + mon2 + " --primary --auto --mode 1920x1080 --output " + mon3 + " --off --output " + mon1 + " --off --output " + mon4 + " --auto --right-of " + mon2 + " --mode 1920x1080" - elif myObj["target"] == "midlefttop": + elif myObj["target"] == "midlefttop": myCmd = "xrandr --output " + mon2 + " --primary --auto --mode 1920x1080 --output " + mon3 + " --auto --right-of " + mon2 + " --mode 1920x1080 --output " + mon1 + " --auto --left-of " + mon2 + " --mode 1920x1080 --output " + mon4 + " --off" - elif myObj["target"] == "build": + elif myObj["target"] == "build": myCmd = "xrandr --output " + mon2 + " --off --output " + mon3 + " --off --output " + mon1 + " --off --output " + mon4 + " --auto --mode 1920x1080" else: - pass - + pass + writeLog(myCmd) if myCmd != "": print(myCmd) @@ -826,12 +832,12 @@ def on_message(client, userdata, msg): # os.startfile(sys.argv[0]) #sys.exit() #print("reconfigure") - subprocess.Popen(['MultiMonitorTool.exe', '/SaveConfig', 'c:\\Program Files\\jaydee\\switcher.cfg']) + subprocess.Popen(['MultiMonitorTool.exe', '/SaveConfig', 'c:\\Program Files\\jaydee\\switcher.cfg']) myCmd = "powershell switcher.ps1 " + str(myObj["target"]) + " " + str(myObj["status"]) writeLog(myCmd) subprocess.Popen(myCmd.split()) time.sleep(1) - subprocess.Popen(['MultiMonitorTool.exe', '/LoadConfig', 'c:\\Program Files\\jaydee\\switcher.cfg']) + subprocess.Popen(['MultiMonitorTool.exe', '/LoadConfig', 'c:\\Program Files\\jaydee\\switcher.cfg']) client.publish("sectorq/feedback", payload='{"action":"resp", "source":"ASUS", "dev":{"display' + str(myObj["target"]) + '":'+ str(myObj["status"]) +'} }' , qos=0, retain=False) if myObj["cmd"] == "displ": print("Display") @@ -841,7 +847,7 @@ def on_message(client, userdata, msg): if myObj["cmd"] == "xrandr": if curos == "Windows": - subprocess.Popen(['MultiMonitorTool.exe', '/LoadConfig', 'c:\\Program Files\\jaydee\\all_on.cfg']) + subprocess.Popen(['MultiMonitorTool.exe', '/LoadConfig', 'c:\\Program Files\\jaydee\\all_on.cfg']) else: print("Display") # os.startfile(sys.argv[0]) @@ -983,10 +989,10 @@ if curos == "Windows": 'TMOBO':'MB_TEMP' } #ks = ["TCPU", "TPCHDIO", "SMEMUTI", "SVIRTMEMUTI", "SCPUUTI", "FCPU", "TGPU1DIO", "SGPU1BIUTI"] - - - - + + + + path = winreg.HKEY_CURRENT_USER try: key = winreg.OpenKeyEx(path, r"SOFTWARE\\FinalWire\\AIDA64\\SensorValues") @@ -1002,8 +1008,8 @@ if curos == "Windows": except: print("aida initializing...") results = {"status":"init"} - - + + else: print("CPU Cnt : {}".format(psutil.cpu_count())) print(psutil.virtual_memory()) @@ -1015,7 +1021,7 @@ if curos == "Windows": print(swap_data) print("MEM : {}".format(mem_data.percent)) print(psutil.getloadavg()) - try: + try: print(psutil.sensors_temperatures()) except: pass @@ -1060,7 +1066,7 @@ else: #cpu_usage = psutil.cpu_percent(interval=1) load1, load5, load15 = psutil.getloadavg() cpu_usage = round((load1/os.cpu_count()) * 100, 1) - + print(mem_data) print(mem_data.percent) print(psutil.disk_usage('/')) @@ -1071,7 +1077,7 @@ else: #print(output) #print(type(output)) #jn1 = json.loads(output) - + #print(str(jn1["coretemp-isa-0000"]["Package id 0"]["temp1_input"])) #print(str(jn1["asus-isa-0000"]["cpu_fan"]["fan1_input"])) #client.publish("sectorq/monitor/" + host.lower(), payload="{\"mb_temp\":0,\"mem_usage\":0,\"cpu_temp\":0,\"cpu_usage\":0,\"gpu_temp\":0,\"gpu_usage\":0}", qos=0, retain=False) @@ -1122,11 +1128,11 @@ else: check_router() elif host.lower() == "nas": print("Getting VM info") - + cmnd = "/share/ZFS530_DATA/.qpkg/QKVM/usr/bin/virsh list --all" writeLog(cmnd) status, output = subprocess.getstatusoutput(cmnd) - l = 1 + l = 1 lines = output.splitlines() VMS = {} for i in lines: @@ -1136,11 +1142,11 @@ else: line = re.split(r" {2,}", i) print(str(line[0].strip()) + " " + str(line[1].strip()) + " " + str(line[2].strip())) VMS[str(line[1].strip())] = str(line[2].strip()) - - - + + + for m in VMS: - + cmnd = "/share/ZFS530_DATA/.qpkg/QKVM/usr/bin/virsh domstate " + m #out = subprocess.Popen(cmnd.split()) writeLog(cmnd) @@ -1149,17 +1155,17 @@ else: if output.strip() == "running": client.publish("sectorq/systems/nas/" + m, payload=1, qos=0, retain=True) else: - client.publish("sectorq/systems/nas/" + m, payload=0, qos=0, retain=True) - - + client.publish("sectorq/systems/nas/" + m, payload=0, qos=0, retain=True) + + if FILE_TIMESTAMP != mtime: writeLog("Script updated ! restarting...") #os.execv(sys.executable, ['python'] + sys.argv) #os.system("/share/ZFS530_DATA/.qpkg/QPython39/bin/python3 mqtt_srv.py") - + if host.lower() == "nas": sys.stdout.flush() - os.execv("/share/ZFS530_DATA/.qpkg/QPython39/bin/python3", sys.argv) + os.execv("/share/ZFS530_DATA/.qpkg/QPython39/bin/python3", sys.argv) if host.lower() == "router" or host.lower() == "omv": #sys.stdout.flush() #os.execv(sys.argv, "")