python线程检测网段脚本!
#!/usr/bin/python
#coding:utf-8
import subprocess //调用shell命令的一个模块
import threading //导入线程模块
def myping(ip):
s=subprocess.call('ping -c2 -i0.1 -W1 %s &>/dev/null' %ip,shell=True)
if s==0:
print "%s is up" %ip
else:
print "%s is down" %ip
net=['176.130.3.%d' %i for i in range(1,255)]
for i in net:
t=threading.Thread(target=myping,args=[i])
t.start()