Files
SnarfCode/scripts/check_peanut_device.py

23 lines
811 B
Python

import paramiko
import sys
sys.stdout.reconfigure(encoding='utf-8')
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('140.44.4.71', username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
def run(cmd):
stdin, stdout, stderr = c.exec_command(cmd)
return stdout.read().decode().strip(), stderr.read().decode().strip()
print("--- PeaNUT Container Logs ---")
out, _ = run("echo 'Katzir476!' | sudo -S docker service logs peanut_peanut --tail 30")
print(out)
print("\n--- Curl http://140.44.4.70:8050/device/server-closet ---")
out, _ = run("curl -s http://140.44.4.70:8050/device/server-closet | grep -i -E 'battery|charge|runtime|cyberpower|or2200|server-closet' | head -n 30")
print("Matches in HTML:\n", out[:500])
c.close()