php - How to test ip response time, can set millisecond timeout?
学习ing
学习ing 2017-06-07 09:23:00
0
1
879

I want to test the response time of a batch of IPs, similar to the response time of ping, which requires milliseconds.
You can set a millisecond-level timeout. If >500ms, it is considered unqualified and continue to the next test.
Both Python and PHP scripts are acceptable

学习ing
学习ing

reply all(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'

Remember to like it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!