Files
SnarfCode/scripts/remediate_swarm_services.py

47 lines
1.5 KiB
Python

import paramiko
import sys
import time
sys.stdout.reconfigure(encoding='utf-8')
key_path = r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet'
def main():
print("=== Connecting to Shipyard Swarm Manager (140.44.4.71) ===")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
c.connect("140.44.4.71", username="root", key_filename=key_path, timeout=10)
except Exception as e:
print(f"Failed to connect to root@140.44.4.71: {e}")
print("Retrying with username=snarf...")
c.connect("140.44.4.71", username="snarf", key_filename=key_path, timeout=10)
def run_cmd(cmd):
print(f"\n>>> Running: {cmd}")
stdin, stdout, stderr = c.exec_command(cmd)
out = stdout.read().decode().strip()
err = stderr.read().decode().strip()
if out:
print(out)
if err:
print(f"[stderr] {err}")
return out, err
# 1. Inspect live Swarm stacks & services
run_cmd("docker stack ls")
run_cmd("docker service ls")
run_cmd("docker ps --filter 'name=heimdall' --filter 'name=pihole' --filter 'name=watchtower'")
# 2. Check Heimdall mount and files
run_cmd("docker inspect $(docker ps -q -f name=heimdall) --format '{{json .Mounts}}' 2>/dev/null || true")
# 3. Check Pi-hole stack status
run_cmd("docker stack ps pihole 2>/dev/null || true")
c.close()
print("\n=== Inspection Complete ===")
if __name__ == '__main__':
main()