feat: add various infrastructure and service diagnostic scripts
This commit is contained in:
@@ -1,30 +1,33 @@
|
||||
import paramiko
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
||||
|
||||
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
||||
# Check pihole config in /etc/pihole
|
||||
stdin, stdout, stderr = ssh.exec_command('k3s kubectl exec -n dns deployment/pihole -- grep -i password /etc/pihole/pihole.toml 2>/dev/null || true')
|
||||
print("pihole.toml password:")
|
||||
print(stdout.read().decode('utf-8', errors='ignore'))
|
||||
|
||||
def check(host, ns, name):
|
||||
print(f"\n=================== {name} ({host}) ===================")
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username="root", key_filename=key_path, timeout=10)
|
||||
|
||||
print("\n--- Pods in ns " + ns + " ---")
|
||||
stdin, stdout, stderr = c.exec_command(f"k3s kubectl -n {ns} get pods -o wide")
|
||||
print(stdout.read().decode('utf-8'))
|
||||
|
||||
print("\n--- Pihole Pod describe/logs ---")
|
||||
stdin, stdout, stderr = c.exec_command(f"k3s kubectl -n {ns} describe deploy/pihole | grep -E 'Image:|Environment|Mounts|Volumes'")
|
||||
print(stdout.read().decode('utf-8'))
|
||||
|
||||
print("\n--- Technitium Pod describe/logs ---")
|
||||
stdin, stdout, stderr = c.exec_command(f"k3s kubectl -n {ns} describe deploy/technitium-dns | grep -E 'Image:|Environment|Mounts|Volumes'")
|
||||
print(stdout.read().decode('utf-8'))
|
||||
|
||||
c.close()
|
||||
# Check pihole env
|
||||
stdin, stdout, stderr = ssh.exec_command('k3s kubectl exec -n dns deployment/pihole -- env | grep -E "WEBPASSWORD|FTLCONF"')
|
||||
print("pihole env:")
|
||||
print(stdout.read().decode('utf-8', errors='ignore'))
|
||||
|
||||
check("140.44.4.11", "infra", "Aerodrome")
|
||||
check("140.44.4.41", "infrastructure", "Spaceport")
|
||||
# Let's test pihole web login via curl inside the pod or to localhost:80
|
||||
stdin, stdout, stderr = ssh.exec_command('k3s kubectl exec -n dns deployment/pihole -- curl -s -I http://localhost/admin/')
|
||||
print("curl localhost/admin/ header:")
|
||||
print(stdout.read().decode('utf-8', errors='ignore'))
|
||||
|
||||
# Check Technitium SSO settings via API using the valid token
|
||||
token = "8d22b3ee9fe8ccbb317679afdbc86959d0ceea8261e0f0c7957d4325a7987d78"
|
||||
stdin, stdout, stderr = ssh.exec_command(f'k3s kubectl exec -n dns deployment/technitium-dns -- curl -s "http://localhost:5380/api/admin/sso/get?token={token}"')
|
||||
print("Technitium SSO get:")
|
||||
print(stdout.read().decode('utf-8', errors='ignore'))
|
||||
|
||||
# Check Technitium info or settings
|
||||
stdin, stdout, stderr = ssh.exec_command(f'k3s kubectl exec -n dns deployment/technitium-dns -- curl -s "http://localhost:5380/api/settings/get?token={token}"')
|
||||
print("Technitium settings get (sample):")
|
||||
print(stdout.read().decode('utf-8', errors='ignore')[:300])
|
||||
|
||||
ssh.close()
|
||||
|
||||
Reference in New Issue
Block a user