36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
import paramiko
|
|
|
|
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("140.44.4.90", username="rancher", key_filename=SSH_KEY, timeout=10)
|
|
|
|
def k8s(cmd):
|
|
full_cmd = f"echo Katzir476! | sudo -S sh -c 'export KUBECONFIG=/etc/rancher/rke2/rke2.yaml; PATH=$PATH:/var/lib/rancher/rke2/bin; {cmd}'"
|
|
_, o, e = c.exec_command(full_cmd)
|
|
return o.read().decode().strip(), e.read().decode().strip()
|
|
|
|
print("=== NODES.LONGHORN.IO DISK STATUS ===")
|
|
out, _ = k8s("kubectl get nodes.longhorn.io -n longhorn-system -o yaml | grep -E 'diskStatus|diskUUID|ready|schedulable|storageAvailable|storageMaximum|path:'")
|
|
print(out[:1500])
|
|
|
|
print("\n=== LSBLK & MOUNTS ON NODE 01 ===")
|
|
out, _ = k8s("lsblk -f; echo '--- DF ---'; df -h | grep -E 'Filesystem|extra-disks|harvester'")
|
|
print(out)
|
|
|
|
# Check all 4 nodes for extra-disks mount
|
|
for ip in ["140.44.4.81", "140.44.4.82", "140.44.4.83", "140.44.4.84"]:
|
|
print(f"\n--- Node {ip} ---")
|
|
try:
|
|
nc = paramiko.SSHClient()
|
|
nc.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
nc.connect(ip, username="rancher", key_filename=SSH_KEY, timeout=5)
|
|
_, o, _ = nc.exec_command("echo Katzir476! | sudo -S lsblk | grep -E 'sd|nvme'; df -h | grep extra")
|
|
print(o.read().decode().strip())
|
|
nc.close()
|
|
except Exception as e:
|
|
print("Error connecting:", e)
|
|
|
|
c.close()
|
|
|