36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
import paramiko
|
|
|
|
NODES = [
|
|
("swm01", "140.44.4.71"),
|
|
("swm02", "140.44.4.72"),
|
|
("swm03", "140.44.4.73"),
|
|
("swm04", "140.44.4.74"),
|
|
("swm05", "140.44.4.75"),
|
|
]
|
|
|
|
def main():
|
|
for name, ip in NODES:
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
try:
|
|
ssh.connect(ip, username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=5)
|
|
stdin, stdout, stderr = ssh.exec_command("systemctl is-active keepalived 2>/dev/null || echo inactive")
|
|
status = stdout.read().decode().strip()
|
|
|
|
stdin, stdout, stderr = ssh.exec_command("ip -4 addr show | grep '140.44.4.70' || true")
|
|
vip = stdout.read().decode().strip()
|
|
|
|
stdin, stdout, stderr = ssh.exec_command("grep -E 'state|priority' /etc/keepalived/keepalived.conf 2>/dev/null || true")
|
|
conf = stdout.read().decode().strip()
|
|
|
|
print(f"[{name} - {ip}] Keepalived: {status} | VIP: {'YES' if '140.44.4.70' in vip else 'NO'}")
|
|
if conf:
|
|
print(f" Config: {conf.splitlines()}")
|
|
ssh.close()
|
|
except Exception as e:
|
|
print(f"[{name} - {ip}] Error:", e)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|