feat: add various infrastructure check and automation scripts
This commit is contained in:
23
scripts/check_disk_contents.py
Normal file
23
scripts/check_disk_contents.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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.81", username="rancher", key_filename=SSH_KEY, timeout=10)
|
||||
|
||||
def run_cmd(cmd):
|
||||
full_cmd = f"echo Katzir476! | sudo -S sh -c '{cmd}'"
|
||||
_, o, e = c.exec_command(full_cmd)
|
||||
return o.read().decode().strip(), e.read().decode().strip()
|
||||
|
||||
print("Mount /dev/sdf to /mnt and check contents:")
|
||||
out, err = run_cmd("mkdir -p /mnt/test && mount /dev/sdf /mnt/test && ls -la /mnt/test")
|
||||
print("sdf:", out, err)
|
||||
|
||||
# Check all devices sdb through sdh
|
||||
for d in ["sdb", "sdc", "sdd", "sde", "sdf", "sdg", "sdh"]:
|
||||
out, _ = run_cmd(f"mkdir -p /mnt/{d} && mount /dev/{d} /mnt/{d} 2>/dev/null && ls -la /mnt/{d} | grep -E 'longhorn|replicas'")
|
||||
print(f"{d}: {out}")
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user