feat: add various infrastructure check and automation scripts
This commit is contained in:
40
scripts/check_real_heimdall_db2.py
Normal file
40
scripts/check_real_heimdall_db2.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import paramiko
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("140.44.4.71", username="snarf", password="Katzir476!", timeout=10)
|
||||
|
||||
py_code = """
|
||||
import sqlite3
|
||||
|
||||
db_path = '/var/lib/docker-data/heimdall/config/www/app.sqlite'
|
||||
con = sqlite3.connect(db_path)
|
||||
cur = con.cursor()
|
||||
|
||||
print('=== PRAGMA table_info(items) ===')
|
||||
for col in cur.execute('PRAGMA table_info(items)').fetchall():
|
||||
print(col)
|
||||
|
||||
print('=== ITEMS COUNT ===')
|
||||
print('Count:', cur.execute('SELECT count(*) FROM items').fetchone()[0])
|
||||
|
||||
print('=== SAMPLE ITEMS ===')
|
||||
for row in cur.execute('SELECT * FROM items').fetchall()[:10]:
|
||||
print(row)
|
||||
|
||||
print('=== SETTINGS ===')
|
||||
for row in cur.execute('SELECT * FROM settings').fetchall():
|
||||
print(row)
|
||||
"""
|
||||
|
||||
stdin, stdout, stderr = c.exec_command("cat > /tmp/inspect_heimdall_real.py")
|
||||
stdin.write(py_code)
|
||||
stdin.close()
|
||||
stdout.channel.recv_exit_status()
|
||||
|
||||
_, o, e = c.exec_command("echo Katzir476! | sudo -S python3 /tmp/inspect_heimdall_real.py")
|
||||
print(o.read().decode())
|
||||
print(e.read().decode())
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user