feat: add various infrastructure check and automation scripts
This commit is contained in:
33
scripts/check_peanut_status.py
Normal file
33
scripts/check_peanut_status.py
Normal file
@@ -0,0 +1,33 @@
|
||||
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):
|
||||
print(f"\n>>> {cmd}")
|
||||
_, o, e = c.exec_command(cmd)
|
||||
out = o.read().decode().strip()
|
||||
if out:
|
||||
print(out)
|
||||
return out
|
||||
|
||||
print("--- PeaNUT Service Status ---")
|
||||
run("echo 'Katzir476!' | sudo -S docker service ps peanut_peanut")
|
||||
run("echo 'Katzir476!' | sudo -S docker service logs peanut_peanut --tail 30")
|
||||
|
||||
print("\n--- Check PeaNUT NPM Proxy Host ---")
|
||||
npm_query = """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 WHERE domain_names LIKE '%peanut%' OR domain_names LIKE '%ups%' OR forward_port=8050").fetchall()
|
||||
for r in rows:
|
||||
print(r)
|
||||
conn.close()
|
||||
"""
|
||||
run(f"""echo 'Katzir476!' | sudo -S python3 -c "{npm_query}" """)
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user