42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
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 = [
|
|
"hostname; free -h | head -2; df -h / | tail -1",
|
|
"docker --version 2>&1; docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' 2>&1",
|
|
"ss -ltnp 2>/dev/null | grep -E ':5432|:3306|:9000|:9300|:8090|:4002|:8000|:9180|:9100|:3000|:8080|:1935|:1337|:8025|:9001' || true",
|
|
"ls /www/server/panel/vhost/nginx/*.conf 2>/dev/null | xargs -I{} basename {}",
|
|
"ls /etc/systemd/system/*.service 2>/dev/null | xargs -I{} basename {} | grep -E 'nomad|lounge|mirotalk|ergo|cnomad' || true",
|
|
"which nginx certbot 2>&1",
|
|
"curl -sI https://nomadro.cn/ | head -3",
|
|
]
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, username=USER, password=PASSWORD, timeout=25)
|
|
try:
|
|
for cmd in CMDS:
|
|
print(f"\n=== {cmd} ===")
|
|
_, o, e = c.exec_command(cmd, timeout=45, get_pty=True)
|
|
out = o.read().decode("utf-8", errors="replace").strip()
|
|
err = e.read().decode("utf-8", errors="replace").strip()
|
|
if out:
|
|
print(out)
|
|
if err:
|
|
print("ERR:", err)
|
|
finally:
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|