Files
SnarfCode/scripts/rancher_status.py

35 lines
980 B
Python

import paramiko
import sys
sys.stdout.reconfigure(encoding='utf-8')
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
try:
client.connect("140.44.4.11", username="root", key_filename=key_path, timeout=10)
print("=== Connected to Aerodrome (140.44.4.11) ===")
cmds = [
"kubectl -n cattle-system get pods -o wide",
"helm list -n cattle-system",
"helm repo list",
"k3s etcd-snapshot list"
]
for cmd in cmds:
print(f"\n--- Running: {cmd} ---")
stdin, stdout, stderr = client.exec_command(f"KUBECONFIG=/etc/rancher/k3s/k3s.yaml {cmd}")
out = stdout.read().decode('utf-8')
err = stderr.read().decode('utf-8')
if out:
print(out.strip())
if err:
print(f"ERR: {err.strip()}")
client.close()
except Exception as e:
print(f"Error: {e}")