26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
import paramiko
|
|
|
|
nodes = ["140.44.44.121", "140.44.44.122", "140.44.44.123", "140.44.44.124"]
|
|
|
|
for ip in nodes:
|
|
try:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(ip, username="root", password="Katzir476!", timeout=10)
|
|
|
|
stdin, stdout, stderr = c.exec_command("racadm serveraction powerstatus")
|
|
power = stdout.read().decode().strip()
|
|
|
|
stdin, stdout, stderr = c.exec_command("racadm get System.ServerInfo.ServiceTag")
|
|
out_tag = stdout.read().decode().strip()
|
|
tag = [line for line in out_tag.splitlines() if line and not line.startswith("racadm") and not line.startswith("[")][-1] if out_tag else "Unknown"
|
|
|
|
stdin, stdout, stderr = c.exec_command("racadm get System.ServerInfo.HostName")
|
|
out_name = stdout.read().decode().strip()
|
|
name = [line for line in out_name.splitlines() if line and not line.startswith("racadm") and not line.startswith("[")][-1] if out_name else "Unknown"
|
|
|
|
print(f"[{ip}] {power} | {tag} | {name}")
|
|
c.close()
|
|
except Exception as e:
|
|
print(f"[{ip}] ERROR: {e}")
|