feat: add script to check pihole-FTL database integrity and query count via SSH
This commit is contained in:
21
scripts/check_ftl_db.py
Normal file
21
scripts/check_ftl_db.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import paramiko
|
||||||
|
|
||||||
|
client = paramiko.SSHClient()
|
||||||
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
|
client.connect("140.44.4.11", username="root", key_filename=r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet", timeout=10)
|
||||||
|
|
||||||
|
def exec_cmd(cmd):
|
||||||
|
stdin, stdout, stderr = client.exec_command(cmd)
|
||||||
|
out = stdout.read().decode()
|
||||||
|
err = stderr.read().decode()
|
||||||
|
return out.strip(), err.strip()
|
||||||
|
|
||||||
|
print("1. Query count in pihole-FTL.db:")
|
||||||
|
out, err = exec_cmd('k3s kubectl exec -n dns deploy/pihole -c pihole -- pihole-FTL sqlite3 /etc/pihole/pihole-FTL.db "SELECT count(*) FROM query_storage;"')
|
||||||
|
print("Count:", out, "Err:", err)
|
||||||
|
|
||||||
|
print("2. FTL integrity check:")
|
||||||
|
out, err = exec_cmd('k3s kubectl exec -n dns deploy/pihole -c pihole -- pihole-FTL sqlite3 /etc/pihole/pihole-FTL.db "PRAGMA integrity_check;"')
|
||||||
|
print("Integrity:", out, "Err:", err)
|
||||||
|
|
||||||
|
client.close()
|
||||||
Reference in New Issue
Block a user