tiny fix
This commit is contained in:
parent
592cdd2b40
commit
589b894165
@ -6,7 +6,9 @@ import socket
|
||||
import os
|
||||
|
||||
UPS_IP = "10.31.41.46"
|
||||
TIME_THRESHOLD = 6
|
||||
TIME_THRESHOLD = 7
|
||||
SHUTDOWN_DELAY = 2
|
||||
|
||||
INTERVAL_LINE = 60
|
||||
INTERVAL_BATTERY = 5
|
||||
OID_ON_BATTERY_TIME = "1.3.6.1.4.1.318.1.1.1.2.2.3.0"
|
||||
@ -88,16 +90,16 @@ def main():
|
||||
if result is None: continue
|
||||
battery_percent = int(result)
|
||||
|
||||
print(f"Batterry {battery_percent}%, {state}, estimated time on battery: {time_on_battery} minutes", flush=True)
|
||||
print(f"Batterry {battery_percent}%, {state}, estimated time on battery: {time_on_battery} minute (treshhold {TIME_THRESHOLD})", flush=True)
|
||||
|
||||
shutdown_status = run_command('shutdown --show')
|
||||
|
||||
if (state == "on-battery") and (time_on_battery < TIME_THRESHOLD) and ("No scheduled shutdown" in shutdown_status):
|
||||
print("UPS is failing, shutting down in 60 seconds...", flush=True)
|
||||
send_email(f"{socket.gethostname()}@vvzvlad.xyz", "UPS is failing, shutting down in 60 seconds...",
|
||||
f"Proxmox node '{socket.gethostname()}': UPS is failing, shutting down in 60 seconds...",
|
||||
print(f"UPS is failing, shutting down in {SHUTDOWN_DELAY} min...", flush=True)
|
||||
send_email(f"{socket.gethostname()}@vvzvlad.xyz", "UPS is failing, shutting down in {SHUTDOWN_DELAY} min.",
|
||||
f"Proxmox node '{socket.gethostname()}': UPS is failing, shutting down in {SHUTDOWN_DELAY} min, 'shutdown -c' to cancel",
|
||||
f"{socket.gethostname()}@vvzvlad.xyz")
|
||||
run_command('shutdown -h 3 "Shutting down due to UPS failure"')
|
||||
run_command(f'shutdown -h {SHUTDOWN_DELAY} "Shutting down due to UPS failure"')
|
||||
|
||||
if (state == "on-line") and ("Shutdown scheduled" in shutdown_status):
|
||||
print("UPS is back online, cancelling shutdown...", flush=True)
|
||||
|
Loading…
Reference in New Issue
Block a user