Files
SnarfCode/scripts/inspect_peanut_container.py

29 lines
1.2 KiB
Python

import paramiko
import sys
sys.stdout.reconfigure(encoding='utf-8')
for node in ["140.44.4.71", "140.44.4.72", "140.44.4.73", "140.44.4.74", "140.44.4.75"]:
try:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(node, username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=5)
stdin, stdout, stderr = c.exec_command("docker ps -a --filter name=peanut --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'")
out = stdout.read().decode().strip()
if out and len(out.splitlines()) > 1:
print(f"--- Node {node} ---")
print(out)
# Inspect the container
_, stdout, _ = c.exec_command("docker inspect $(docker ps -q --filter name=peanut) --format '{{json .Config.Env}}'")
env = stdout.read().decode().strip()
print("Env:", env)
_, stdout, _ = c.exec_command("docker logs --tail 30 $(docker ps -q --filter name=peanut)")
logs = stdout.read().decode().strip()
print("Logs:\n", logs)
c.close()
except Exception as e:
print(f"Error on {node}: {e}")