bitwarden

This commit is contained in:
jaydee
2024-07-07 20:22:06 +02:00
parent b57b8cc200
commit 1ab9d43b22
2 changed files with 65 additions and 26 deletions

View File

@@ -19,7 +19,7 @@ import random
import requests
#import psutil
stats = {}
VERSION = "1.0.26"
VERSION = "1.0.28"
curos = platform.system()
host = platform.node().lower()
print(host)
@@ -868,8 +868,11 @@ def on_message(client, userdata, msg):
else:
if host == "nas" or host == "octopi":
subprocess.Popen(["/sbin/poweroff"])
elif host == "openmediavault" or host == "omv":
elif host == "openmediavault" or host == "omv" or host == "amd" or host == "ryzen":
subprocess.Popen(["poweroff"])
elif host == "amd" or host == "ryzen":
subprocess.Popen(["systemctl suspend"])
else:
#subprocess.Popen(["/bin/systemctl", "suspend", "-i"])
#subprocess.Popen(["sudo", "pm-suspend"])
@@ -931,7 +934,15 @@ client.will_set("home-assistant/" + host.lower() + "/hwstats", payload=payload,
client.on_connect = on_connect
client.on_message = on_message
writeLog(MQTT_HOST)
client.connect(MQTT_HOST, MQTT_PORT, 25)
connected = False
while not connected:
try:
client.connect(MQTT_HOST, MQTT_PORT, 25)
connected = True
except:
writeLog("Failed to connect repeating...")
time.sleep(10)
# client.publish("sectorq/status", payload="{'action':'connect', 'system':'" + host + "', 'ip': '" + IP + "', 'mac':'" + mac + "', 'ver':'?'}", qos=0, retain=False)
@@ -1054,7 +1065,8 @@ else:
NEXT_CHECK = int(time.time()) + 20
writeLog("Blalala : Next : " + str(NEXT_CHECK))
if host.lower() == "asus" or host.lower() == "morefine":
if host.lower() == "asus" or host.lower() == "morefine" or host.lower() == "ryzen":
writeLog("Blalala : AAA")
print(psutil.sensors_temperatures())
#print(psutil.sensors_fans())
sences = psutil.sensors_temperatures()
@@ -1068,19 +1080,25 @@ else:
cpu_data = sences["k10temp"][0]
except:
cpu_data = "None"
writeLog(cpu_data)
print("CPUDATA")
print(cpu_data)
print("#"*40)
mb_data = sences["acpitz"][0]
print("MBDATA")
print(mb_data)
print(mb_data.current)
try:
mb_data = sences["acpitz"][0]
print(mb_data)
print(mb_data.current)
mb_data = mb_data.current
except:
mb_data = 0
print("#"*40)
try:
print(psutil.sensors_fans())
fan_data = psutil.sensors_fans()["asus"][0].current
except:
fan_data = "None"
@@ -1104,7 +1122,8 @@ 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='{"status":"on", "version":"' + VERSION + '","TCPU":"NA", "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) + '", "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False)
writeLog('{"status":"on", "version":"' + VERSION + '","TCPU":"NA", "MB_TEMP":' + str(mb_data) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":"' + str(fan_data) + '", "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}')
client.publish("home-assistant/" + host + "/hwstats", payload='{"status":"on", "version":"' + VERSION + '","TCPU":"NA", "MB_TEMP":' + str(mb_data) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":"' + str(fan_data) + '", "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)
elif host.lower() == "openmediavault" or host.lower() == "omv":
#print(psutil.sensors_temperatures())