php - 如何測試ip回應時間,可以設定毫秒超時?
学习ing
学习ing 2017-06-07 09:23:00
0
1
901

我要測試一批ip回應時間,類似ping的回應時間,要求毫秒級的。
可以設定毫秒超時,如 >500ms 就不合格,繼續測試下一個。
Python、PHP腳本都可以

学习ing
学习ing

全部回覆(1)
世界只因有你
#coding=utf8
import os
ip_list=['192.168.0.1','192.168.0.2','192.168.0.3','192.168.0.106']
for each in ip_list:
    a=os.popen('ping -n 1 %s'%each).read().decode('gbk')
    b=a.find('=')
    c=a.find('ms')
    time=a[b+7:c]
    try:
        if int(str(time))>=500:
            print 'time >= 500ms'
        else:
            print each+'  :  '+time+'ms'
    except Exception as e:
        print 'lost'

記得給讚喲

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!