22 lines
836 B
Python
22 lines
836 B
Python
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
def main():
|
|
for ip, node in [('140.44.4.71', 'snshpd4lnxswm01'), ('140.44.4.72', 'snshpd4lnxswm02')]:
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect(ip, username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
|
|
print(f"=== {node} ({ip}) ===")
|
|
stdin, stdout, stderr = ssh.exec_command('sudo ss -tulpn | grep -E ":80 |:81 |:443 " || true')
|
|
print("SS:\n", stdout.read().decode())
|
|
stdin, stdout, stderr = ssh.exec_command('sudo docker ps -a --filter "name=nginx" --format "{{.ID}} {{.Status}} {{.Names}}"')
|
|
print("Containers:\n", stdout.read().decode())
|
|
ssh.close()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|