赞
踩
from pysnmp.hlapi import *
from threading import Thread
import subprocess
from queue import Queue
from multiprocessing.dummy import Pool as ThreadPool
import multiprocessing
num_threads=254
q = Queue()
liveips=['192.168.183.1','192.168.183.2','192.168.183.3','192.168.183.4','192.168.183.5'
,'192.168.183.6','192.168.183.7','192.168.183.8','192.168.183.9','192.168.183.144'
'192.168.183.10',]
def sysinfo(aliveips):
g = getCmd(SnmpEngine(),
CommunityData('public'),
UdpTransportTarget((aliveips, 161)),
ContextData(),
ObjectType(ObjectIdentity('.1.3.6.1.2.1.1.1.0')))
try:
print(str(next(g))+aliveips)
except:
print('no permission')
pool = multiprocessing.Pool(254)
pool.map(sysinfo, liveips)
pool.close()
pool.join()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。