diff --git a/build/mqtt_srv/Analysis-00.toc b/build/mqtt_srv/Analysis-00.toc index 30a86a3..cafd433 100644 --- a/build/mqtt_srv/Analysis-00.toc +++ b/build/mqtt_srv/Analysis-00.toc @@ -309,12 +309,6 @@ ('multiprocessing', 'C:\\Program Files\\Python310\\lib\\multiprocessing\\__init__.py', 'PYMODULE'), - ('stringprep', - 'C:\\Program Files\\Python310\\lib\\stringprep.py', - 'PYMODULE'), - ('tracemalloc', - 'C:\\Program Files\\Python310\\lib\\tracemalloc.py', - 'PYMODULE'), ('_py_abc', 'C:\\Program Files\\Python310\\lib\\_py_abc.py', 'PYMODULE'), ('getpass', 'C:\\Program Files\\Python310\\lib\\getpass.py', 'PYMODULE'), ('nturl2path', @@ -327,6 +321,12 @@ ('http.cookiejar', 'C:\\Program Files\\Python310\\lib\\http\\cookiejar.py', 'PYMODULE'), + ('stringprep', + 'C:\\Program Files\\Python310\\lib\\stringprep.py', + 'PYMODULE'), + ('tracemalloc', + 'C:\\Program Files\\Python310\\lib\\tracemalloc.py', + 'PYMODULE'), ('ping3', 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\ping3\\__init__.py', 'PYMODULE'), @@ -807,12 +807,12 @@ ('_asyncio.pyd', 'C:\\Program Files\\Python310\\DLLs\\_asyncio.pyd', 'EXTENSION'), - ('libssl-1_1.dll', - 'C:\\Program Files\\Python310\\DLLs\\libssl-1_1.dll', - 'BINARY'), ('libcrypto-1_1.dll', 'C:\\Program Files\\Python310\\DLLs\\libcrypto-1_1.dll', 'BINARY'), + ('libssl-1_1.dll', + 'C:\\Program Files\\Python310\\DLLs\\libssl-1_1.dll', + 'BINARY'), ('python3.dll', 'C:\\Program Files\\Python310\\python3.dll', 'BINARY'), ('libffi-7.dll', 'C:\\Program Files\\Python310\\DLLs\\libffi-7.dll', @@ -822,10 +822,10 @@ [('base_library.zip', 'X:\\__GITLAB\\python\\build\\mqtt_srv\\base_library.zip', 'DATA'), - ('certifi\\cacert.pem', - 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\certifi\\cacert.pem', - 'DATA'), ('certifi\\py.typed', 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\certifi\\py.typed', + 'DATA'), + ('certifi\\cacert.pem', + 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\certifi\\cacert.pem', 'DATA')], []) diff --git a/build/mqtt_srv/EXE-00.toc b/build/mqtt_srv/EXE-00.toc index 7224c6e..51ee3a4 100644 --- a/build/mqtt_srv/EXE-00.toc +++ b/build/mqtt_srv/EXE-00.toc @@ -88,12 +88,12 @@ ('_asyncio.pyd', 'C:\\Program Files\\Python310\\DLLs\\_asyncio.pyd', 'EXTENSION'), - ('libssl-1_1.dll', - 'C:\\Program Files\\Python310\\DLLs\\libssl-1_1.dll', - 'BINARY'), ('libcrypto-1_1.dll', 'C:\\Program Files\\Python310\\DLLs\\libcrypto-1_1.dll', 'BINARY'), + ('libssl-1_1.dll', + 'C:\\Program Files\\Python310\\DLLs\\libssl-1_1.dll', + 'BINARY'), ('python3.dll', 'C:\\Program Files\\Python310\\python3.dll', 'BINARY'), ('libffi-7.dll', 'C:\\Program Files\\Python310\\DLLs\\libffi-7.dll', @@ -101,16 +101,16 @@ ('base_library.zip', 'X:\\__GITLAB\\python\\build\\mqtt_srv\\base_library.zip', 'DATA'), - ('certifi\\cacert.pem', - 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\certifi\\cacert.pem', - 'DATA'), ('certifi\\py.typed', 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\certifi\\py.typed', + 'DATA'), + ('certifi\\cacert.pem', + 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\certifi\\cacert.pem', 'DATA')], [], False, False, - 1671871456, + 1672427170, [('runw.exe', 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\PyInstaller\\bootloader\\Windows-64bit-intel\\runw.exe', 'EXECUTABLE')]) diff --git a/build/mqtt_srv/PKG-00.toc b/build/mqtt_srv/PKG-00.toc index 2e5f9fc..36ac12f 100644 --- a/build/mqtt_srv/PKG-00.toc +++ b/build/mqtt_srv/PKG-00.toc @@ -81,12 +81,12 @@ ('_asyncio.pyd', 'C:\\Program Files\\Python310\\DLLs\\_asyncio.pyd', 'EXTENSION'), - ('libssl-1_1.dll', - 'C:\\Program Files\\Python310\\DLLs\\libssl-1_1.dll', - 'BINARY'), ('libcrypto-1_1.dll', 'C:\\Program Files\\Python310\\DLLs\\libcrypto-1_1.dll', 'BINARY'), + ('libssl-1_1.dll', + 'C:\\Program Files\\Python310\\DLLs\\libssl-1_1.dll', + 'BINARY'), ('python3.dll', 'C:\\Program Files\\Python310\\python3.dll', 'BINARY'), ('libffi-7.dll', 'C:\\Program Files\\Python310\\DLLs\\libffi-7.dll', @@ -94,11 +94,11 @@ ('base_library.zip', 'X:\\__GITLAB\\python\\build\\mqtt_srv\\base_library.zip', 'DATA'), - ('certifi\\cacert.pem', - 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\certifi\\cacert.pem', - 'DATA'), ('certifi\\py.typed', 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\certifi\\py.typed', + 'DATA'), + ('certifi\\cacert.pem', + 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\certifi\\cacert.pem', 'DATA')], False, False, diff --git a/build/mqtt_srv/PYZ-00.pyz b/build/mqtt_srv/PYZ-00.pyz index 810d8a5..29dcf8f 100644 Binary files a/build/mqtt_srv/PYZ-00.pyz and b/build/mqtt_srv/PYZ-00.pyz differ diff --git a/build/mqtt_srv/PYZ-00.toc b/build/mqtt_srv/PYZ-00.toc index cc1ac64..cee69d3 100644 --- a/build/mqtt_srv/PYZ-00.toc +++ b/build/mqtt_srv/PYZ-00.toc @@ -281,12 +281,6 @@ ('multiprocessing', 'C:\\Program Files\\Python310\\lib\\multiprocessing\\__init__.py', 'PYMODULE'), - ('stringprep', - 'C:\\Program Files\\Python310\\lib\\stringprep.py', - 'PYMODULE'), - ('tracemalloc', - 'C:\\Program Files\\Python310\\lib\\tracemalloc.py', - 'PYMODULE'), ('_py_abc', 'C:\\Program Files\\Python310\\lib\\_py_abc.py', 'PYMODULE'), ('getpass', 'C:\\Program Files\\Python310\\lib\\getpass.py', 'PYMODULE'), ('nturl2path', @@ -299,6 +293,12 @@ ('http.cookiejar', 'C:\\Program Files\\Python310\\lib\\http\\cookiejar.py', 'PYMODULE'), + ('stringprep', + 'C:\\Program Files\\Python310\\lib\\stringprep.py', + 'PYMODULE'), + ('tracemalloc', + 'C:\\Program Files\\Python310\\lib\\tracemalloc.py', + 'PYMODULE'), ('ping3', 'C:\\Users\\jaydee\\AppData\\Roaming\\Python\\Python310\\site-packages\\ping3\\__init__.py', 'PYMODULE'), diff --git a/build/mqtt_srv/base_library.zip b/build/mqtt_srv/base_library.zip index 24eb357..33f3402 100644 Binary files a/build/mqtt_srv/base_library.zip and b/build/mqtt_srv/base_library.zip differ diff --git a/build/mqtt_srv/mqtt_srv.pkg b/build/mqtt_srv/mqtt_srv.pkg index c8737e5..6dd73f4 100644 Binary files a/build/mqtt_srv/mqtt_srv.pkg and b/build/mqtt_srv/mqtt_srv.pkg differ diff --git a/dist/mqtt_srv.exe b/dist/mqtt_srv.exe index b63933a..8dbc1ec 100644 Binary files a/dist/mqtt_srv.exe and b/dist/mqtt_srv.exe differ diff --git a/mqtt_srv.py b/mqtt_srv.py index b640284..2430b63 100644 --- a/mqtt_srv.py +++ b/mqtt_srv.py @@ -149,6 +149,7 @@ def check_router(): # if output == "allow":\ writeLog("Payload : " + str(json.dumps(stats))) ''' + stats["status"] = "on" client.publish("home-assistant/router/hwstats", json.dumps(stats), qos=0, retain=True) #client.publish("sectorq/systems/router/stats", payload=json.dumps(stats), qos=0, retain=True) #else: @@ -916,22 +917,14 @@ def on_message(client, userdata, msg): print("not a json!") client = mqtt.Client() -payload = "off" client.username_pw_set("jaydee", password="jaydee1") -client.will_set("sectorq/systems/" + host.lower() + "/stat", payload=payload, qos=0, retain=True) +client.will_set("home-assistant/" + host + "/hwstats", payload='{"status":"off"}', qos=0, retain=True) + client.on_connect = on_connect client.on_message = on_message writeLog(MQTT_HOST) client.connect(MQTT_HOST, MQTT_PORT, 25) -# client.publish("sectorq/status", payload="{'action':'connect', 'system':'" + host + "', 'ip': '" + IP + "', 'mac':'" + mac + "', 'ver':'?'}", qos=0, retain=False) - - -# Blocking call that processes network traffic, dispatches callbacks and -# handles reconnecting. -# Other loop*() functions are available that give a threaded interface and a -# manual interface. - def checkIfProcessRunning(processName): ''' Check if there is any running process that contains the given name processName. @@ -994,6 +987,7 @@ if curos == "Windows": results[aide_refs[k]] = value[0] except: pass + results["status"] = "on" except: print("aida initializing...") results = {} @@ -1018,12 +1012,11 @@ if curos == "Windows": print(psutil.sensors_fans()) except: pass - results = {"version":VERSION,"MB_TEMP":"NA", "MEM_UTIL":str(mem_data.percent), "CPU_TEMP":"NA", "FAN_CPU":"NA", "VMEM_UTIL":swap_data.percent, "CPU_UTIL":cpu_usage, "GPU_TEMP":"NA", "GPU_UTIL":"NA"} + results = {"status":"on", "version":VERSION,"MB_TEMP":"NA", "MEM_UTIL":str(mem_data.percent), "CPU_TEMP":"NA", "FAN_CPU":"NA", "VMEM_UTIL":swap_data.percent, "CPU_UTIL":cpu_usage, "GPU_TEMP":"NA", "GPU_UTIL":"NA"} print(json.dumps(results)) r = json.dumps(results) #client.publish("home-assistant/" + host + "/hwstats", payload='{"TPCHDIO":"' + str(results["TPCHDIO"]) + '", "SMEMUTI":"' + str(results["SMEMUTI"]) + '", "TCPU":"' + str(results["TCPU"]) + '", "TGPU1DIO":"' + str(results["TGPU1DIO"]) + '", "SGPU1BIUTI":"' + str(results["SGPU1BIUTI"]) + '", "FCPU":"' + str(results["FCPU"]) + '", "SVIRTMEMUTI":"' + str(results["SVIRTMEMUTI"]) + '", "SCPUUTI":"' + str(results["SCPUUTI"]) + '"}', qos=0, retain=False) client.publish("home-assistant/" + host + "/hwstats", payload=r, qos=0, retain=False) - client.publish("sectorq/systems/" + host.lower() + "/stat", payload="on", qos=0, retain=True) #print(json.dumps(stats)) #writeLog(json.dumps(stats)) else: @@ -1070,8 +1063,7 @@ else: #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) - client.publish("home-assistant/" + host + "/hwstats", payload='{"version":"' + VERSION + '","MB_TEMP":' + str(mb_data.current) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":' + str(fan_data.current) + ', "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False) - client.publish("sectorq/systems/" + host.lower() + "/stat", payload="on", qos=0, retain=True) + client.publish("home-assistant/" + host + "/hwstats", payload='{"status":"on","version":"' + VERSION + '","MB_TEMP":' + str(mb_data.current) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":' + str(fan_data.current) + ', "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False) elif host.lower() == "openmediavault" or host.lower() == "omv": #print(psutil.sensors_temperatures()) #print(psutil.sensors_fans()) @@ -1112,7 +1104,7 @@ else: #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) - client.publish("home-assistant/" + host + "/hwstats", payload='{"version":"' + VERSION + '","reboot":"' + str(reboot_pending) + '", "uptime":"' + str(sys_uptime) + '", "raid_usage": ' + str(disk_usage) + ',"rsync":"' + str(stat_rsync) +'", "MB_TEMP":' + str(mb_data.current) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":0, "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False) + client.publish("home-assistant/" + host + "/hwstats", payload='{"status":"on", "version":"' + VERSION + '","reboot":"' + str(reboot_pending) + '", "uptime":"' + str(sys_uptime) + '", "raid_usage": ' + str(disk_usage) + ',"rsync":"' + str(stat_rsync) +'", "MB_TEMP":' + str(mb_data.current) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":0, "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False) elif host.lower() == "router": check_router() elif host.lower() == "nas": diff --git a/mqtt_srv.pyw b/mqtt_srv.pyw index b640284..03a6d21 100644 --- a/mqtt_srv.pyw +++ b/mqtt_srv.pyw @@ -916,22 +916,14 @@ def on_message(client, userdata, msg): print("not a json!") client = mqtt.Client() -payload = "off" client.username_pw_set("jaydee", password="jaydee1") -client.will_set("sectorq/systems/" + host.lower() + "/stat", payload=payload, qos=0, retain=True) +client.will_set("home-assistant/" + host + "/hwstats", payload='{"status":"off"}', qos=0, retain=True) + client.on_connect = on_connect client.on_message = on_message writeLog(MQTT_HOST) client.connect(MQTT_HOST, MQTT_PORT, 25) -# client.publish("sectorq/status", payload="{'action':'connect', 'system':'" + host + "', 'ip': '" + IP + "', 'mac':'" + mac + "', 'ver':'?'}", qos=0, retain=False) - - -# Blocking call that processes network traffic, dispatches callbacks and -# handles reconnecting. -# Other loop*() functions are available that give a threaded interface and a -# manual interface. - def checkIfProcessRunning(processName): ''' Check if there is any running process that contains the given name processName. @@ -994,6 +986,7 @@ if curos == "Windows": results[aide_refs[k]] = value[0] except: pass + results["status"] = "on" except: print("aida initializing...") results = {} @@ -1018,12 +1011,11 @@ if curos == "Windows": print(psutil.sensors_fans()) except: pass - results = {"version":VERSION,"MB_TEMP":"NA", "MEM_UTIL":str(mem_data.percent), "CPU_TEMP":"NA", "FAN_CPU":"NA", "VMEM_UTIL":swap_data.percent, "CPU_UTIL":cpu_usage, "GPU_TEMP":"NA", "GPU_UTIL":"NA"} + results = {"status":"on", "version":VERSION,"MB_TEMP":"NA", "MEM_UTIL":str(mem_data.percent), "CPU_TEMP":"NA", "FAN_CPU":"NA", "VMEM_UTIL":swap_data.percent, "CPU_UTIL":cpu_usage, "GPU_TEMP":"NA", "GPU_UTIL":"NA"} print(json.dumps(results)) r = json.dumps(results) #client.publish("home-assistant/" + host + "/hwstats", payload='{"TPCHDIO":"' + str(results["TPCHDIO"]) + '", "SMEMUTI":"' + str(results["SMEMUTI"]) + '", "TCPU":"' + str(results["TCPU"]) + '", "TGPU1DIO":"' + str(results["TGPU1DIO"]) + '", "SGPU1BIUTI":"' + str(results["SGPU1BIUTI"]) + '", "FCPU":"' + str(results["FCPU"]) + '", "SVIRTMEMUTI":"' + str(results["SVIRTMEMUTI"]) + '", "SCPUUTI":"' + str(results["SCPUUTI"]) + '"}', qos=0, retain=False) client.publish("home-assistant/" + host + "/hwstats", payload=r, qos=0, retain=False) - client.publish("sectorq/systems/" + host.lower() + "/stat", payload="on", qos=0, retain=True) #print(json.dumps(stats)) #writeLog(json.dumps(stats)) else: @@ -1070,8 +1062,7 @@ else: #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) - client.publish("home-assistant/" + host + "/hwstats", payload='{"version":"' + VERSION + '","MB_TEMP":' + str(mb_data.current) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":' + str(fan_data.current) + ', "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False) - client.publish("sectorq/systems/" + host.lower() + "/stat", payload="on", qos=0, retain=True) + client.publish("home-assistant/" + host + "/hwstats", payload='{"status":"on","version":"' + VERSION + '","MB_TEMP":' + str(mb_data.current) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":' + str(fan_data.current) + ', "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False) elif host.lower() == "openmediavault" or host.lower() == "omv": #print(psutil.sensors_temperatures()) #print(psutil.sensors_fans()) @@ -1112,7 +1103,7 @@ else: #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) - client.publish("home-assistant/" + host + "/hwstats", payload='{"version":"' + VERSION + '","reboot":"' + str(reboot_pending) + '", "uptime":"' + str(sys_uptime) + '", "raid_usage": ' + str(disk_usage) + ',"rsync":"' + str(stat_rsync) +'", "MB_TEMP":' + str(mb_data.current) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":0, "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False) + client.publish("home-assistant/" + host + "/hwstats", payload='{"status":"on", "version":"' + VERSION + '","reboot":"' + str(reboot_pending) + '", "uptime":"' + str(sys_uptime) + '", "raid_usage": ' + str(disk_usage) + ',"rsync":"' + str(stat_rsync) +'", "MB_TEMP":' + str(mb_data.current) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":0, "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False) elif host.lower() == "router": check_router() elif host.lower() == "nas":