Compare commits

...

10 Commits

Author SHA1 Message Date
fde5d705cc chat gpt is retarded sometimes 2024-10-13 20:15:27 -05:00
595bea6539 import sys 2024-10-13 19:23:16 -05:00
ffeba267ec small edit 2024-10-13 18:49:01 -05:00
02a9624e31 write usb_acpi 2024-10-13 18:42:39 -05:00
e9c9555ba1 add usb acpi 2024-10-13 18:39:41 -05:00
3269abe626 add ssh client close 2024-10-12 03:24:28 -05:00
accb805db6 batt values tweaked based on testing 2024-10-12 03:10:09 -05:00
b691efb86b change battery values based on testing 2024-10-12 02:47:49 -05:00
e108e7fbcc add delay before nas shutdown 2024-10-12 02:39:58 -05:00
a8d95c9cd9 fix reqs 2024-10-12 02:35:39 -05:00
3 changed files with 15 additions and 4 deletions

View File

@ -123,6 +123,7 @@ def shutdown_nas():
stdin, stdout, stderr = client.exec_command('sudo shutdown') stdin, stdout, stderr = client.exec_command('sudo shutdown')
for line in stdout: for line in stdout:
print(line.strip()) print(line.strip())
client.close()
except Exception as e: except Exception as e:
logger.error(e) logger.error(e)
@ -148,7 +149,7 @@ def pwr_online(battery):
logger.info(message) logger.info(message)
send_email(f"{ups_id}: Power On Line", message) send_email(f"{ups_id}: Power On Line", message)
send_discord(message) send_discord(message)
if ups_id == "Server" and battery > 90: if ups_id == "Server" and battery > 75:
wake_up(battery) wake_up(battery)
def pwr_offline(battery): def pwr_offline(battery):
@ -171,8 +172,8 @@ def batt_crit(battery):
if ups_id == "Server": if ups_id == "Server":
for node in servers: for node in servers:
shutdown_pve(node) shutdown_pve(node)
time.sleep(120)
shutdown_nas() shutdown_nas()
time.sleep(300)
# Main Loop # Main Loop
def main(): def main():
@ -191,8 +192,8 @@ def main():
else: else:
logger.info(f"UPS status changed to: {status}") logger.info(f"UPS status changed to: {status}")
prev_status = status prev_status = status
elif status == "OB DISCHRG" and battery < 50: elif status == "OB DISCHRG" and battery < 70:
if battery < 25: if battery < 65:
batt_crit(battery) batt_crit(battery)
if ups_id == "Server": if ups_id == "Server":
for node in servers: for node in servers:

View File

@ -3,5 +3,6 @@ ping3
config config
discord discord
paramiko paramiko
requests
proxmoxer proxmoxer
wakeonlan wakeonlan

9
usb_acpi.py Normal file
View File

@ -0,0 +1,9 @@
import sys
import time
with open('/dev/hidg0', 'wb') as f:
f.write(b'\x01')
time.sleep(0.3)
f.write(b'\x00')
sys.exit()