东西很简单,可扩展性很大
import multiprocessing
import time,os,math
def func(msg):
output=os.popen("ssh %s hostname" %(msg)).read()
print output
if __name__ =="__main__":
flist=open('b').readlines()
pool =multiprocessing.Pool(processes=7)
for i in flist:
msg=i.replace('\n','')
pool.apply_async(func, (msg, ))
pool.close()
pool.join()
print"Sub-process(es) done."
b文件是个IP列表
一个IP一行即可
阅读(4647) | 评论(0) | 转发(0) |