From 1fe16429a4dc8ccf24c530c921a934c5aa840788 Mon Sep 17 00:00:00 2001 From: Snarf Date: Sat, 7 Nov 2026 13:02:12 -0500 Subject: [PATCH] feat: add script to check pihole-FTL database integrity and query count via SSH --- scripts/check_ftl_db.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 scripts/check_ftl_db.py diff --git a/scripts/check_ftl_db.py b/scripts/check_ftl_db.py new file mode 100644 index 0000000..dc87dba --- /dev/null +++ b/scripts/check_ftl_db.py @@ -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()