feat: add homelab deployment configs, documentation, and automation scripts
This commit is contained in:
36
scripts/verify_grafana_dashboard.py
Normal file
36
scripts/verify_grafana_dashboard.py
Normal file
@@ -0,0 +1,36 @@
|
||||
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 -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}'")
|
||||
print(run(f"kubectl exec {pod} -- cat /var/lib/grafana-dashboards/ai-stack-dashboard.json | grep -i 'title' | head -n 5"))
|
||||
|
||||
py_script = """import sqlite3
|
||||
import subprocess
|
||||
out = subprocess.check_output("kubectl exec deployment/grafana -- cat /var/lib/grafana/grafana.db", shell=True)
|
||||
with open("/tmp/g.db", "wb") as f:
|
||||
f.write(out)
|
||||
conn = sqlite3.connect('/tmp/g.db')
|
||||
cur = conn.cursor()
|
||||
print('=== DATASOURCES ===')
|
||||
for row in cur.execute('SELECT id, name, type, url FROM data_source').fetchall():
|
||||
print(row)
|
||||
print('=== DASHBOARDS ===')
|
||||
for row in cur.execute('SELECT id, title, slug, uid FROM dashboard').fetchall():
|
||||
print(row)
|
||||
"""
|
||||
|
||||
stdin, stdout, stderr = c.exec_command("cat > /tmp/check_g.py && python3 /tmp/check_g.py")
|
||||
stdin.write(py_script)
|
||||
stdin.close()
|
||||
print(stdout.read().decode())
|
||||
print(stderr.read().decode())
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user