Files
SnarfCode/scripts/check_dns_status.py

45 lines
1.8 KiB
Python

import paramiko
def check_cluster(host, name):
print(f"=== Checking {name} ({host}) ===")
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
stdin, stdout, stderr = ssh.exec_command('k3s kubectl get pods -n dns -o wide')
print("Pods:")
print(stdout.read().decode())
stdin, stdout, stderr = ssh.exec_command('k3s kubectl exec -n dns deployment/pihole -- pihole -v')
print("Pihole version:")
print(stdout.read().decode())
# Set password explicitly
stdin, stdout, stderr = ssh.exec_command('k3s kubectl exec -n dns deployment/pihole -- pihole setpassword snarfnetadmin')
out = stdout.read().decode()
err = stderr.read().decode()
print("Set password with pihole setpassword:")
print(out)
if err:
print("ERR:", err)
if "Unknown" in out or "invalid" in out.lower() or err:
stdin, stdout, stderr = ssh.exec_command('k3s kubectl exec -n dns deployment/pihole -- pihole -a -p snarfnetadmin')
print("Fallback pihole -a -p:")
print(stdout.read().decode())
# Check Technitium login via API
stdin, stdout, stderr = ssh.exec_command('k3s kubectl exec -n dns deployment/technitium-dns -- curl -s "http://localhost:5380/api/user/login?user=admin&pass=snarfnetadmin"')
login_res = stdout.read().decode()
print("Technitium API Login:", login_res)
# Check Technitium SSO config
stdin, stdout, stderr = ssh.exec_command("k3s kubectl exec -n dns deployment/technitium-dns -- cat /etc/dns/auth.config 2>/dev/null || echo 'No auth.config'")
print("Technitium auth.config:")
print(stdout.read().decode())
ssh.close()
check_cluster('140.44.4.11', 'Aerodrome')
check_cluster('140.44.4.41', 'Spaceport')