0
我試圖在一堆使用python的Paramiko模塊的遠程服務器上運行多個命令。Paramiko在運行簡單命令時運行在150多臺服務器上時掛起
我試圖運行的命令是簡單的命令,比如cat,lspci(帶有grep)以及只有1行輸出的小腳本。
事情是,如果我提供很少的機器(〜50),它的工作原理很好。 當我嘗試在許多機器上運行腳本時,問題就開始了。
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username='root', password='pass')
transport = ssh.get_transport()
channel = transport.open_session()
stdin, stdout, stderr = ssh.exec_command(cmd)
for line in stdout.readlines():
line = line.strip()
sheet1.write(row_line,0,host,style_cell) # writing to xls file
sheet1.write(row_line,1,line,style_cell) # writing to xls file
while channel.recv_ready():
channel.recv(1024)
ssh.close()
expect:
print stdout
print stderr
這是標準輸出,標準錯誤,我得到:
paramiko.ChannelFile from paramiko.Channel 2 (EOF received) (open) window=2097152
paramiko.Transport at 0xce44c9d0L (cipher aes128-ctr, 128 bits) (active; 2 open channel(s))
請指點,
謝謝!
啓用paramiko調試日誌記錄,以查看是否可以從paramiko模塊引出更多信息。 'logging.getLogger( 「的paramiko」)。setLevel(logging.DEBUG)'。 – 2013-04-26 01:16:55