's'
This commit is contained in:
40
scripts/ssh-check-ntfy.py
Normal file
40
scripts/ssh-check-ntfy.py
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST = os.getenv("NOMAD_SSH_HOST", "82.157.112.245")
|
||||
USER = os.getenv("NOMAD_SSH_USER", "ubuntu")
|
||||
PASSWORD = os.getenv("NOMAD_SSH_PASSWORD", "Xiao4669805")
|
||||
|
||||
CMDS = [
|
||||
"docker ps -a | grep -i ntfy || true",
|
||||
"curl -sI http://127.0.0.1:9180/ | head -8",
|
||||
"curl -sI https://ntfy.nomadro.cn/ | head -10",
|
||||
"curl -skI https://ntfy.nomadro.cn/ | head -10",
|
||||
"sudo cat /www/server/panel/vhost/nginx/ntfy.nomadro.cn.conf 2>/dev/null | head -60",
|
||||
"sudo ls /etc/letsencrypt/live/ | grep ntfy || true",
|
||||
"sudo certbot certificates 2>/dev/null | grep -A3 ntfy || true",
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASSWORD, timeout=30)
|
||||
try:
|
||||
for cmd in CMDS:
|
||||
full = f"echo '{PASSWORD}' | sudo -S bash -lc \"{cmd}\""
|
||||
print(f"\n=== {cmd} ===")
|
||||
_, o, e = c.exec_command(full, timeout=60, get_pty=True)
|
||||
sys.stdout.buffer.write(o.read())
|
||||
sys.stdout.buffer.write(e.read())
|
||||
finally:
|
||||
c.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user