46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
import paramiko
|
|
import sys
|
|
|
|
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):
|
|
_, o, e = c.exec_command(cmd)
|
|
return o.read().decode().strip()
|
|
|
|
# Check direct curl to port 8050 on Swarm VIP and nodes
|
|
for ip in ["140.44.4.70", "140.44.4.71", "140.44.4.74"]:
|
|
res = run(f"curl -s -o /dev/null -w '%{{http_code}}' http://{ip}:8050")
|
|
print(f"Curl http://{ip}:8050 -> HTTP {res}")
|
|
|
|
# Check NPM database
|
|
script = '''
|
|
import sqlite3
|
|
conn = sqlite3.connect('/var/lib/docker/volumes/nginx-proxy-manager_nginx-data/_data/database.sqlite')
|
|
cur = conn.cursor()
|
|
rows = cur.execute("SELECT id, domain_names, forward_host, forward_port, enabled FROM proxy_host").fetchall()
|
|
for r in rows:
|
|
if any(k in str(r).lower() for k in ["peanut", "ups", "8050"]):
|
|
print(r)
|
|
conn.close()
|
|
'''
|
|
out = run(f"echo 'Katzir476!' | sudo -S python3 -c {repr(script)}")
|
|
print("\nNPM matching records:\n", out)
|
|
|
|
# Check Heimdall tile for PeaNUT
|
|
heimdall_script = '''
|
|
import sqlite3
|
|
con = sqlite3.connect('/var/lib/docker-data/heimdall/config/www/app.sqlite')
|
|
cur = con.cursor()
|
|
row = cur.execute("SELECT id, title, url FROM items WHERE title LIKE '%peanut%' OR title LIKE '%nut%'").fetchall()
|
|
print("Heimdall tile for PeaNUT:", row)
|
|
con.close()
|
|
'''
|
|
out_h = run(f"echo 'Katzir476!' | sudo -S python3 -c {repr(heimdall_script)}")
|
|
print(out_h)
|
|
|
|
c.close()
|
|
|