import paramiko, sys
sys.stdout.reconfigure(encoding="utf-8")

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("192.168.1.76", username="root", password="7309208104")

# fail2ban - banned IPs per jail
for jail in ["nginx-unauthorized", "nginx-badbots", "nginx-deny"]:
    _, out, _ = ssh.exec_command(f"docker exec swag fail2ban-client status {jail} 2>/dev/null")
    print(f"=== fail2ban {jail} ===")
    print(out.read().decode())

# hledej 403 v access logu pro msgs
_, out, _ = ssh.exec_command(
    "docker exec swag grep 'msgs.buzalka.cz' /config/log/nginx/access.log | grep ' 403 ' | tail -20"
)
print("=== access.log msgs 403 ===")
print(out.read().decode() or "(nic)")

# hledej všechny POST /upload z dnešního dne
_, out, _ = ssh.exec_command(
    "docker exec swag grep 'POST /upload' /config/log/nginx/access.log | grep '01/Jun/2026' | tail -20"
)
print("=== POST /upload dnes ===")
print(out.read().decode() or "(nic)")

ssh.close()
