我用这种方式:
servers = ["192.168.100.161", "192.168.100.162", "192.168.100.163"]
top_command = "top -b -n 1"
host_config = make_host_config(servers)
client = ParallelSSHClient(servers, timeout=2, num_retries=1, retry_delay=1, host_config=host_config)
try:
output = client.run_command(top_command, sudo=True)
print([(k, [x for x in v.stdout], [x for x in v.stderr]) for (k, v) in output.items()])
for host, host_response in output:
print(host, host_response)
except Exception as e:
print("failed to connect some host: ", e)
我现在得到了什么:一个例外。
无法连接某些主机: (“连接到主机 '%s:%s' 时出错 - %s - 重试 %s/%s”, '192.168.100.161', 22, 'timed out', 1, 1)
我希望得到: 来自可用服务器的响应来自不可用服务器的错误
怎么实现啊各位?