feat: add various infrastructure check and automation scripts
This commit is contained in:
31
scripts/inspect_peanut_service.py
Normal file
31
scripts/inspect_peanut_service.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import paramiko
|
||||
import sys
|
||||
import json
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect('140.44.4.71', username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
||||
|
||||
def run(cmd):
|
||||
stdin, stdout, stderr = c.exec_command(cmd)
|
||||
return stdout.read().decode().strip(), stderr.read().decode().strip()
|
||||
|
||||
print("--- Service Inspect ---")
|
||||
out, _ = run("echo 'Katzir476!' | sudo -S docker service inspect peanut_peanut")
|
||||
try:
|
||||
data = json.loads(out)
|
||||
spec = data[0]['Spec']['TaskTemplate']['ContainerSpec']
|
||||
print("Image:", spec.get('Image'))
|
||||
print("Env:", spec.get('Env'))
|
||||
print("Mounts:", spec.get('Mounts'))
|
||||
except Exception as e:
|
||||
print("Parse error:", e)
|
||||
print(out[:1000])
|
||||
|
||||
print("\n--- Service Tasks / Nodes ---")
|
||||
out, _ = run("echo 'Katzir476!' | sudo -S docker service ps peanut_peanut --no-trunc")
|
||||
print(out)
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user