feat: add various infrastructure check and automation scripts
This commit is contained in:
50
scripts/diagnose_peanut.py
Normal file
50
scripts/diagnose_peanut.py
Normal file
@@ -0,0 +1,50 @@
|
||||
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):
|
||||
stdin, stdout, stderr = c.exec_command(cmd)
|
||||
out = stdout.read().decode('utf-8', errors='replace')
|
||||
err = stderr.read().decode('utf-8', errors='replace')
|
||||
return out.strip(), err.strip()
|
||||
|
||||
print("docker service ls:")
|
||||
out, _ = run("docker service ls")
|
||||
print(out)
|
||||
|
||||
print("\nPython3 test:")
|
||||
out, err = run("python3 --version")
|
||||
print(out, err)
|
||||
|
||||
# Run python script inside a temporary script file on the server so quoting doesn't get messed up
|
||||
check_py = """
|
||||
import sqlite3
|
||||
try:
|
||||
conn = sqlite3.connect('/var/lib/docker-data/heimdall/config/www/app.sqlite')
|
||||
print("HEIMDALL TILES:")
|
||||
for row in conn.execute("SELECT id, title, url, pinned FROM items"):
|
||||
print(row)
|
||||
conn.close()
|
||||
except Exception as e:
|
||||
print("Heimdall error:", e)
|
||||
|
||||
try:
|
||||
conn = sqlite3.connect('/var/lib/docker/volumes/nginx-proxy-manager_nginx-data/_data/database.sqlite')
|
||||
print("NPM PROXY HOSTS:")
|
||||
for row in conn.execute("SELECT id, domain_names, forward_host, forward_port, enabled FROM proxy_host"):
|
||||
print(row)
|
||||
conn.close()
|
||||
except Exception as e:
|
||||
print("NPM error:", e)
|
||||
"""
|
||||
|
||||
run(f"cat << 'EOF' > /tmp/check_dbs.py\n{check_py}\nEOF")
|
||||
out, err = run("echo 'Katzir476!' | sudo -S python3 /tmp/check_dbs.py")
|
||||
print("\nDB check results:\n", out)
|
||||
if err: print("\nDB check err:\n", err)
|
||||
|
||||
c.close()
|
||||
Reference in New Issue
Block a user