30 lines
1.4 KiB
Python
30 lines
1.4 KiB
Python
import paramiko
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect('140.44.4.11', username='root', 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()
|
|
|
|
pod = run("kubectl get pod -n monitoring -l app.kubernetes.io/name=uptime-kuma -o jsonpath='{.items[0].metadata.name}'")
|
|
|
|
print("--- TABLES ---")
|
|
print(run(f"""kubectl exec -n monitoring {pod} -- mariadb --socket=/app/data/run/mariadb.sock -u root -e "USE kuma; SHOW TABLES;" """))
|
|
|
|
print("\n--- TAG TABLE SCHEMA ---")
|
|
print(run(f"""kubectl exec -n monitoring {pod} -- mariadb --socket=/app/data/run/mariadb.sock -u root -e "USE kuma; DESCRIBE tag; DESCRIBE monitor_tag;" """))
|
|
|
|
print("\n--- EXISTING TAGS ---")
|
|
print(run(f"""kubectl exec -n monitoring {pod} -- mariadb --socket=/app/data/run/mariadb.sock -u root -e "USE kuma; SELECT * FROM tag;" """))
|
|
|
|
print("\n--- ALL MONITORS ---")
|
|
print(run(f"""kubectl exec -n monitoring {pod} -- mariadb --socket=/app/data/run/mariadb.sock -u root -e "USE kuma; SELECT id, name, type, url, hostname, port, active FROM monitor ORDER BY id;" """))
|
|
|
|
print("\n--- EXISTING STATUS PAGES ---")
|
|
print(run(f"""kubectl exec -n monitoring {pod} -- mariadb --socket=/app/data/run/mariadb.sock -u root -e "USE kuma; SELECT id, slug, title, description, published FROM status_page;" """))
|
|
|
|
c.close()
|
|
|