add return to normal mode
This commit is contained in:
parent
415eb2695b
commit
4bb0fb0a4f
@ -6,8 +6,8 @@ import socket
|
||||
import os
|
||||
|
||||
ups_ip = "10.31.41.46"
|
||||
time_threshold = 4
|
||||
interval = 20
|
||||
time_threshold = 6
|
||||
interval = 60
|
||||
|
||||
def parse_time(time_str):
|
||||
try:
|
||||
@ -51,13 +51,15 @@ def main():
|
||||
|
||||
print(f"Time on battery: {time_on_battery} minutes, State: {state}", flush=True)
|
||||
|
||||
if time_on_battery != False and time_on_battery < time_threshold:
|
||||
if state == "on-battery":
|
||||
shutdown_status = run_command('shutdown --show 2>&1')
|
||||
if "No scheduled shutdown" in shutdown_status:
|
||||
|
||||
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...", f"{socket.gethostname()}@vvzvlad.xyz")
|
||||
run_command('sudo shutdown -h 1 "Shutting down due to UPS failure"')
|
||||
run_command('sudo shutdown -h 3 "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)
|
||||
run_command('sudo shutdown -c')
|
||||
|
||||
if state == "on-battery":
|
||||
time.sleep(5)
|
||||
|
Loading…
Reference in New Issue
Block a user