import paramiko import sys sys.stdout.reconfigure(encoding='utf-8') # 1. Inspect Gotify database on Swarm print("=================== GOTIFY (Swarm 140.44.4.71) ===================") ssh_swm = paramiko.SSHClient() ssh_swm.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_swm.connect('140.44.4.71', username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) def run_swm(cmd): _, out, err = ssh_swm.exec_command(cmd) res = out.read().decode('utf-8', errors='replace').strip() if res: print(res) run_swm("cat c:\\Users\\Snarf\\OneDrive\\Desktop\\code\\SnarfCode\\docker-deployments\\gotify.yml 2>/dev/null || true") run_swm("sudo docker service inspect gotify_gotify --format '{{json .Spec.TaskTemplate.ContainerSpec.Mounts}}'") run_swm("sudo docker run --rm -v gotify_gotify_data:/data alpine ls -la /data 2>/dev/null || find /var/lib/docker/volumes/ -name 'gotify.db' 2>/dev/null") # Query gotify.db if found run_swm("""python3 -c ' import sqlite3, glob db_files = glob.glob("/var/lib/docker/volumes/**/gotify.db", recursive=True) print("Gotify DB files:", db_files) for db in db_files: try: conn = sqlite3.connect(db) cur = conn.cursor() print("Tables in", db) for row in cur.execute("SELECT name FROM sqlite_master WHERE type=\"table\""): print(" ", row[0]) print("Applications count:", cur.execute("SELECT count(*) FROM applications").fetchone()[0]) print("Clients count:", cur.execute("SELECT count(*) FROM clients").fetchone()[0]) print("Messages count:", cur.execute("SELECT count(*) FROM messages").fetchone()[0]) except Exception as e: print("Err reading", db, e) '""") ssh_swm.close() # 2. Inspect Semaphore BoltDB on Spaceport print("\n=================== SEMAPHORE (Spaceport 140.44.4.41) ===================") ssh_sp = paramiko.SSHClient() ssh_sp.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_sp.connect('140.44.4.41', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) def run_sp(cmd): _, out, err = ssh_sp.exec_command(cmd) res = out.read().decode('utf-8', errors='replace').strip() if res: print(res) run_sp("kubectl exec -n infrastructure deployment/semaphore -- ls -lh /var/lib/semaphore/database.boltdb") # Let's inspect projects and templates using semaphore CLI or strings run_sp("kubectl exec -n infrastructure deployment/semaphore -- strings /var/lib/semaphore/database.boltdb | grep -E 'project|playbook|inventory|repository' | head -n 30") ssh_sp.close()