Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1364438
  • 博文数量: 185
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2664
  • 用 户 组: 普通用户
  • 注册时间: 2016-07-01 13:46
个人简介

鸟在笼中,恨关羽不能张飞;Survival of the fittest

文章分类

全部博文(185)

分类: 系统运维

2013-11-20 18:42:08

东西很简单,可扩展性很大

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一行即可


阅读(4546) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~