feat: add various infrastructure check and automation scripts
This commit is contained in:
32
scripts/check_peanut_logs.py
Normal file
32
scripts/check_peanut_logs.py
Normal file
@@ -0,0 +1,32 @@
|
||||
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.74', username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
||||
|
||||
def run(cmd):
|
||||
stdin, stdout, stderr = c.exec_command(cmd, timeout=10)
|
||||
return stdout.read().decode().strip(), stderr.read().decode().strip()
|
||||
|
||||
print("--- Container logs on 140.44.4.74 ---")
|
||||
cid, _ = run("echo 'Katzir476!' | sudo -S docker ps -q -f name=peanut_peanut")
|
||||
print("CID:", cid)
|
||||
if cid:
|
||||
logs, _ = run(f"echo 'Katzir476!' | sudo -S docker logs --tail 30 {cid}")
|
||||
print("LOGS:\n", logs)
|
||||
|
||||
print("\n--- Files in /mnt/swarm_shared/legacy_volumes/peanut ---")
|
||||
out, _ = run("echo 'Katzir476!' | sudo -S ls -la /mnt/swarm_shared/legacy_volumes/peanut")
|
||||
print(out)
|
||||
|
||||
# Check what SQLite or config files are inside /mnt/swarm_shared/legacy_volumes/peanut
|
||||
out, _ = run("echo 'Katzir476!' | sudo -S find /mnt/swarm_shared/legacy_volumes/peanut -type f")
|
||||
print("Files found:\n", out)
|
||||
|
||||
# If db exists, check tables / contents
|
||||
out, _ = run("python3 -c 'import urllib.request; print(urllib.request.urlopen(\"http://140.44.4.70:8050/api/devices\").read().decode())' 2>&1")
|
||||
print("API /api/devices:", out)
|
||||
|
||||
c.close()
|
||||
Reference in New Issue
Block a user