国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語言編程技術(shù)及教程分享平臺!
分類導(dǎo)航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務(wù)器之家 - 腳本之家 - Python - Python實現(xiàn)快速多線程ping的方法

Python實現(xiàn)快速多線程ping的方法

2020-07-23 10:42guoyh Python

這篇文章主要介紹了Python實現(xiàn)快速多線程ping的方法,實例分析了Python多線程及ICMP數(shù)據(jù)包的發(fā)送技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了Python實現(xiàn)快速多線程ping的方法。分享給大家供大家參考。具體如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python
#_*_coding:utf-8_*_
#
'''
名稱:快速多線程ping程序
開發(fā):gyhong gyh9711
日期:20:51 2011-04-25
'''
import pexpect
import datetime
from threading import Thread
host=["192.168.1.1","192.168.1.123","192.168.2.1",
"192.168.1.1","192.168.1.123","192.168.2.1",
"192.168.1.1","192.168.1.123","192.168.2.1",
"192.168.1.1","192.168.1.123","192.168.2.1",
"192.168.1.1"]
report_ok=[]
report_error=[]
class PING(Thread):
  def __init__(self,ip):
    Thread.__init__(self)
    self.ip=ip
  def run(self):
    Curtime = datetime.datetime.now() 
    #Scrtime = Curtime + datetime.timedelta(0,minute,0)
    #print("[%s]主機[%s]" % (Curtime,self.ip))
    ping=pexpect.spawn("ping -c1 %s" % (self.ip))
    check=ping.expect([pexpect.TIMEOUT,"1 packets transmitted, 1 received, 0% packet loss"],2)
    if check == 0:
      print("[%s] 超時 %s" % (Curtime,self.ip))
    elif check == 1:
      print ("[%s] %s 可達(dá)" % (Curtime,self.ip))
    else:
      print("[%s] 主機%s 不可達(dá)" % (Curtime,self.ip))
#多線程同時執(zhí)行
T_thread=[]
for i in host:
  t=PING(i)
  T_thread.append(t)
for i in range(len(T_thread)):
  T_thread[i].start()
#
#print ("\n=========問題主機情況如下==========\n")
#output(report_error)
#print ("\n=========正常主機情況如下==========\n")
#output(report_ok)

執(zhí)行結(jié)果:

administrator@nagios:/win/pexpect$ ./ping.py
[2011-04-25 21:30:22.126981] 192.168.1.1 可達(dá)
[2011-04-25 21:30:22.148376] 192.168.1.1 可達(dá)
[2011-04-25 21:30:22.179846] 192.168.1.1 可達(dá)
[2011-04-25 21:30:22.203691] 192.168.1.1 可達(dá)
[2011-04-25 21:30:22.227696] 192.168.2.1 可達(dá)
[2011-04-25 21:30:22.134049] 超時 192.168.1.123
[2011-04-25 21:30:22.145610] 超時 192.168.2.1
[2011-04-25 21:30:22.157558] 超時 192.168.1.123
[2011-04-25 21:30:22.167898] 超時 192.168.2.1
[2011-04-25 21:30:22.197572] 超時 192.168.1.123
[2011-04-25 21:30:22.202430] 超時 192.168.2.1
[2011-04-25 21:30:22.215561] 超時 192.168.1.123
[2011-04-25 21:30:22.229952] 超時 192.168.1.1

希望本文所述對大家的Python程序設(shè)計有所幫助。

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 亚洲欧美一区二区视频 | 色av成人| 精品久久久久久久久久久下田 | 天堂va蜜桃一区二区三区漫画版 | 亚洲国产高清美女在线观看 | 国产精品一区二区三区免费 | 女男羞羞视频网站免费 | 国产精品18久久久 | 欧美一区二区三区在线观看视频 | 欧美成人精品激情在线观看 | 成人在线免费视频 | 久久久久久久久久久久99 | 特黄色一级片 | 亚洲免费一区二区 | 亚洲在线第一页 | 国产香蕉视频 | 国产aⅴ | 国产欧美日韩一级大片 | 91视频在线免费观看 | 久久99久久99 | 亚洲精品中文字幕在线观看 | 日韩电影免费在线观看中文字幕 | 欧美 亚洲 另类 激情 另类 | 成人亚洲精品 | 黄色片网址在线观看 | 欧美一区二区三区久久久久久桃花 | 精品久久久久久久 | 在线无码 | 欧美久久精品 | 欧美日韩国产一区二区三区 | 亚洲欧美视频 | 1000部精品久久久久久久久 | 奇米影视7777 | 91传媒在线播放 | 视频在线一区二区 | 亚洲国产中文字幕在线 | av一二三区| 久久亚洲一区 | а天堂中文最新一区二区三区 | 亚洲深深色噜噜狠狠网站 | 欧美亚洲三级 |