返回列表 发帖

CentOS8使用多进程+Ping

操作系统的版本信息:
[root@centos8 ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
[root@centos8 ~]#
[root@centos8 ~]# uname -r
4.18.0-193.el8.x86_64


Python的版本信息:
[root@centos8 ~]# python3 --version
Python 3.6.8



############

例子一:

脚本"xx.py"的内容:(主进程)
[root@centos8 ~]# cat xx.py
#coding=utf-8
import multiprocessing

from file_1 import func1 #调用脚本"file_1.py"的函数func1()
from file_2 import func2 #调用脚本"file_2.py"的函数func2()

def func_main(): #有两个子进程
        process_1 = multiprocessing.Process(target=func1,args=())
        process_2 = multiprocessing.Process(target=func2,args=())
       
        process_1.start()
        process_2.start()
       
        process_1.join()
        process_2.join()
       
if __name__ == '__main__':

        index_1 = 0
        while index_1 < 3: #主进程执行3次后自动结束
                func_main()
                index_1 = index_1 + 1


######

脚本"file_1.py"的内容:
[root@centos8 ~]# cat file_1.py
#coding=utf-8
import os,time

from datetime import datetime
date_time_format = '%Y-%m-%d %H:%M:%S'

def date_time_str(date_time):
        return datetime.strftime(date_time, date_time_format)

def func1():

        Key_t =f"\n\n检测时间:{date_time_str(datetime.now())} \n"
       
        Path_1 = "/root/1.txt"
        f_name = open(Path_1,'a') #写入(追加)具体检测时间到文件
        f_name.write(Key_t)
        f_name.close()
       
        #调用Linux命令
        os.system("ping 47.75.39.177 -c 10 >> /root/1.txt")
       
        time.sleep(120) #子进程一休眠120秒;各个子进程的休眠时间要保持一致
       


######

脚本"file_2.py"的内容:
[root@centos8 ~]# cat file_2.py
#coding=utf-8
import os,time

from datetime import datetime
date_time_format = '%Y-%m-%d %H:%M:%S'

def date_time_str(date_time):
        return datetime.strftime(date_time, date_time_format)

def func2():

        Key_t =f"\n\n检测时间:{date_time_str(datetime.now())} \n"
       
        Path_1 = "/root/2.log"
        f_name = open(Path_1,'a')
        f_name.write(Key_t)
        f_name.close()
       
        os.system("ping www.baidu.com -c 10 >> /root/2.log")
       
        time.sleep(120) #子进程二休眠120秒;各个子进程的休眠时间要保持一致


######

脚本"xx.py"运行中的效果:(组合键Ctrl+c可以结束脚本的运行)
图片1.png


######

文件/root/1.txt自动记录的数据:(有三次的Ping结果)
[root@centos8 ~]# cat 1.txt


检测时间:2020-03-03 11:08:51
PING 47.75.39.177 (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177: icmp_seq=1 ttl=128 time=61.1 ms
64 bytes from 47.75.39.177: icmp_seq=2 ttl=128 time=34.5 ms
64 bytes from 47.75.39.177: icmp_seq=3 ttl=128 time=31.1 ms
64 bytes from 47.75.39.177: icmp_seq=4 ttl=128 time=46.6 ms
64 bytes from 47.75.39.177: icmp_seq=5 ttl=128 time=38.5 ms
64 bytes from 47.75.39.177: icmp_seq=6 ttl=128 time=36.1 ms
64 bytes from 47.75.39.177: icmp_seq=7 ttl=128 time=33.1 ms
64 bytes from 47.75.39.177: icmp_seq=8 ttl=128 time=37.6 ms
64 bytes from 47.75.39.177: icmp_seq=9 ttl=128 time=39.9 ms
64 bytes from 47.75.39.177: icmp_seq=10 ttl=128 time=39.7 ms

--- 47.75.39.177 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 33ms
rtt min/avg/max/mdev = 31.096/39.822/61.124/8.187 ms


检测时间:2020-03-03 11:11:00
PING 47.75.39.177 (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177: icmp_seq=1 ttl=128 time=50.2 ms
64 bytes from 47.75.39.177: icmp_seq=2 ttl=128 time=37.4 ms
64 bytes from 47.75.39.177: icmp_seq=3 ttl=128 time=34.2 ms
64 bytes from 47.75.39.177: icmp_seq=4 ttl=128 time=36.1 ms
64 bytes from 47.75.39.177: icmp_seq=5 ttl=128 time=36.2 ms
64 bytes from 47.75.39.177: icmp_seq=6 ttl=128 time=39.5 ms
64 bytes from 47.75.39.177: icmp_seq=7 ttl=128 time=33.6 ms
64 bytes from 47.75.39.177: icmp_seq=8 ttl=128 time=39.7 ms
64 bytes from 47.75.39.177: icmp_seq=9 ttl=128 time=45.3 ms
64 bytes from 47.75.39.177: icmp_seq=10 ttl=128 time=70.8 ms

--- 47.75.39.177 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 44ms
rtt min/avg/max/mdev = 33.580/42.287/70.804/10.678 ms


检测时间:2020-03-03 11:13:09
PING 47.75.39.177 (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177: icmp_seq=1 ttl=128 time=47.2 ms
64 bytes from 47.75.39.177: icmp_seq=2 ttl=128 time=38.2 ms
64 bytes from 47.75.39.177: icmp_seq=3 ttl=128 time=37.3 ms
64 bytes from 47.75.39.177: icmp_seq=4 ttl=128 time=36.3 ms
64 bytes from 47.75.39.177: icmp_seq=5 ttl=128 time=35.1 ms
64 bytes from 47.75.39.177: icmp_seq=6 ttl=128 time=36.7 ms
64 bytes from 47.75.39.177: icmp_seq=7 ttl=128 time=38.5 ms
64 bytes from 47.75.39.177: icmp_seq=8 ttl=128 time=39.3 ms
64 bytes from 47.75.39.177: icmp_seq=9 ttl=128 time=38.5 ms
64 bytes from 47.75.39.177: icmp_seq=10 ttl=128 time=35.2 ms

--- 47.75.39.177 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 37ms
rtt min/avg/max/mdev = 35.091/38.236/47.207/3.286 ms
[root@centos8 ~]#



######

文件/root/2.log自动记录的数据:(所有子进程的开始时间都基本一致)
[root@centos8 ~]# cat 2.log


检测时间:2020-03-03 11:08:51
PING www.a.shifen.com (183.232.231.172) 56(84) bytes of data.
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=1 ttl=128 time=30.1 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=2 ttl=128 time=30.1 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=3 ttl=128 time=27.2 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=4 ttl=128 time=29.2 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=5 ttl=128 time=27.9 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=6 ttl=128 time=28.3 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=7 ttl=128 time=31.8 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=8 ttl=128 time=28.8 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=9 ttl=128 time=26.8 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=10 ttl=128 time=28.5 ms

--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 36ms
rtt min/avg/max/mdev = 26.797/28.856/31.772/1.417 ms


检测时间:2020-03-03 11:11:00
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=1 ttl=128 time=31.5 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=2 ttl=128 time=32.1 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=3 ttl=128 time=30.1 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=4 ttl=128 time=30.7 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=5 ttl=128 time=25.6 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=6 ttl=128 time=27.4 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=7 ttl=128 time=31.4 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=8 ttl=128 time=50.4 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=9 ttl=128 time=28.5 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=10 ttl=128 time=53.2 ms

--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 43ms
rtt min/avg/max/mdev = 25.640/34.090/53.155/9.073 ms


检测时间:2020-03-03 11:13:09
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=1 ttl=128 time=25.7 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=2 ttl=128 time=34.6 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=3 ttl=128 time=29.0 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=4 ttl=128 time=27.9 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=5 ttl=128 time=32.1 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=6 ttl=128 time=30.10 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=7 ttl=128 time=30.4 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=8 ttl=128 time=34.1 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=9 ttl=128 time=29.4 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=10 ttl=128 time=28.6 ms

--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 40ms
rtt min/avg/max/mdev = 25.686/30.280/34.606/2.631 ms
[root@centos8 ~]#








############
############

例子二:

脚本"xx.py"的内容:(主进程)
[root@centos8 ~]# cat xx.py
#coding=utf-8
import multiprocessing

from file_1 import func1 #调用脚本"file_1.py"的函数func1()
from file_2 import func2 #调用脚本"file_2.py"的函数func2()
from file_2 import func3 #调用脚本"file_2.py"的函数func3()

def func_main(): #有三个子进程
        process_1 = multiprocessing.Process(target=func1,args=())
        process_2 = multiprocessing.Process(target=func2,args=())
        process_3 = multiprocessing.Process(target=func3,args=())

        process_1.start()
        process_2.start()
        process_3.start()

        process_1.join()
        process_2.join()
        process_3.join()

if __name__ == '__main__':

        while True: #主进程会无限次地自动执行下去
                func_main()


######

脚本"file_1.py"的内容:
[root@centos8 ~]# cat file_1.py
#coding=utf-8
import os,time

from datetime import datetime
date_time_format = '%Y-%m-%d %H:%M:%S'

def date_time_str(date_time):
        return datetime.strftime(date_time, date_time_format)

def func1():
        Key_t =f"\n\n检测时间:{date_time_str(datetime.now())} \n"
       
        Path_1 = "/root/1.txt"
        f_name = open(Path_1,'a') #写入(追加)具体检测时间到文件
        f_name.write(Key_t)
        f_name.close()
       
        #调用Linux命令
        os.system("ping 47.75.39.177 -c 10 >> /root/1.txt")
       
        time.sleep(60) #子进程一休眠60秒;各个子进程的休眠时间要保持一致


######

脚本"file_2.py"的内容:
[root@centos8 ~]# cat file_2.py
#coding=utf-8
import os,time

from datetime import datetime
date_time_format = '%Y-%m-%d %H:%M:%S'

def date_time_str(date_time):
        return datetime.strftime(date_time, date_time_format)

def func2():
        Key_t =f"\n\n检测时间:{date_time_str(datetime.now())} \n"
       
        Path_1 = "/root/2.log"
        f_name = open(Path_1,'a')
        f_name.write(Key_t)
        f_name.close()
       
        os.system("ping www.baidu.com -c 10 >> /root/2.log")
       
        time.sleep(60) #子进程二休眠60秒;各个子进程的休眠时间要保持一致


def func3():
        Key_t =f"\n\n检测时间:{date_time_str(datetime.now())} \n"
       
        Path_1 = "/root/3.log"
        f_name = open(Path_1,'a')
        f_name.write(Key_t)
        f_name.close()
       
        os.system("ping www.sina.com -c 10 >> /root/3.log")
       
        time.sleep(60) #子进程三休眠60秒;各个子进程的休眠时间要保持一致
       

######

脚本"xx.py"运行中的效果:(组合键Ctrl+c可以结束脚本的运行)
图片2.png


######

文件/root/1.txt自动记录的数据:(以下只是其中连续四次的结果)
[root@centos8 ~]# cat 1.txt


检测时间:2020-03-03 11:37:16
PING 47.75.39.177 (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177: icmp_seq=1 ttl=128 time=56.0 ms
64 bytes from 47.75.39.177: icmp_seq=2 ttl=128 time=30.6 ms
64 bytes from 47.75.39.177: icmp_seq=3 ttl=128 time=30.7 ms
64 bytes from 47.75.39.177: icmp_seq=4 ttl=128 time=30.6 ms
64 bytes from 47.75.39.177: icmp_seq=5 ttl=128 time=33.2 ms
64 bytes from 47.75.39.177: icmp_seq=6 ttl=128 time=34.3 ms
64 bytes from 47.75.39.177: icmp_seq=7 ttl=128 time=32.3 ms
64 bytes from 47.75.39.177: icmp_seq=8 ttl=128 time=34.1 ms
64 bytes from 47.75.39.177: icmp_seq=9 ttl=128 time=29.4 ms
64 bytes from 47.75.39.177: icmp_seq=10 ttl=128 time=32.4 ms

--- 47.75.39.177 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 39ms
rtt min/avg/max/mdev = 29.438/34.365/56.003/7.380 ms


检测时间:2020-03-03 11:38:25
PING 47.75.39.177 (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177: icmp_seq=1 ttl=128 time=57.2 ms
64 bytes from 47.75.39.177: icmp_seq=2 ttl=128 time=43.8 ms
64 bytes from 47.75.39.177: icmp_seq=3 ttl=128 time=62.7 ms
64 bytes from 47.75.39.177: icmp_seq=4 ttl=128 time=32.4 ms
64 bytes from 47.75.39.177: icmp_seq=5 ttl=128 time=34.3 ms
64 bytes from 47.75.39.177: icmp_seq=6 ttl=128 time=33.5 ms
64 bytes from 47.75.39.177: icmp_seq=7 ttl=128 time=32.6 ms
64 bytes from 47.75.39.177: icmp_seq=8 ttl=128 time=29.1 ms
64 bytes from 47.75.39.177: icmp_seq=9 ttl=128 time=33.1 ms
64 bytes from 47.75.39.177: icmp_seq=10 ttl=128 time=32.5 ms

--- 47.75.39.177 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 29ms
rtt min/avg/max/mdev = 29.067/39.116/62.650/11.076 ms


检测时间:2020-03-03 11:39:34
PING 47.75.39.177 (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177: icmp_seq=1 ttl=128 time=81.2 ms
64 bytes from 47.75.39.177: icmp_seq=2 ttl=128 time=89.1 ms
64 bytes from 47.75.39.177: icmp_seq=3 ttl=128 time=32.2 ms
64 bytes from 47.75.39.177: icmp_seq=4 ttl=128 time=32.0 ms
64 bytes from 47.75.39.177: icmp_seq=5 ttl=128 time=32.6 ms
64 bytes from 47.75.39.177: icmp_seq=6 ttl=128 time=33.1 ms
64 bytes from 47.75.39.177: icmp_seq=7 ttl=128 time=30.0 ms
64 bytes from 47.75.39.177: icmp_seq=8 ttl=128 time=32.2 ms
64 bytes from 47.75.39.177: icmp_seq=9 ttl=128 time=32.8 ms
64 bytes from 47.75.39.177: icmp_seq=10 ttl=128 time=32.6 ms

--- 47.75.39.177 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 33ms
rtt min/avg/max/mdev = 30.035/42.784/89.118/21.269 ms


检测时间:2020-03-03 11:40:43
PING 47.75.39.177 (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177: icmp_seq=1 ttl=128 time=64.6 ms
64 bytes from 47.75.39.177: icmp_seq=2 ttl=128 time=34.2 ms
64 bytes from 47.75.39.177: icmp_seq=3 ttl=128 time=30.8 ms
64 bytes from 47.75.39.177: icmp_seq=4 ttl=128 time=40.3 ms
64 bytes from 47.75.39.177: icmp_seq=5 ttl=128 time=33.1 ms
64 bytes from 47.75.39.177: icmp_seq=6 ttl=128 time=31.4 ms
64 bytes from 47.75.39.177: icmp_seq=7 ttl=128 time=38.7 ms
64 bytes from 47.75.39.177: icmp_seq=8 ttl=128 time=34.3 ms
64 bytes from 47.75.39.177: icmp_seq=9 ttl=128 time=38.7 ms
64 bytes from 47.75.39.177: icmp_seq=10 ttl=128 time=50.3 ms

--- 47.75.39.177 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 45ms
rtt min/avg/max/mdev = 30.819/39.643/64.555/9.912 ms
[root@centos8 ~]#



######

文件/root/2.log自动记录的数据:(以下只是其中连续四次的结果)
[root@centos8 ~]# cat 2.log


检测时间:2020-03-03 11:37:16
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=1 ttl=128 time=36.6 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=2 ttl=128 time=26.0 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=3 ttl=128 time=29.5 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=4 ttl=128 time=29.9 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=5 ttl=128 time=26.1 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=6 ttl=128 time=33.9 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=7 ttl=128 time=31.8 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=8 ttl=128 time=28.1 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=9 ttl=128 time=29.1 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=10 ttl=128 time=25.7 ms

--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 32ms
rtt min/avg/max/mdev = 25.711/29.661/36.622/3.403 ms


检测时间:2020-03-03 11:38:25
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=1 ttl=128 time=30.10 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=2 ttl=128 time=27.2 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=3 ttl=128 time=34.6 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=4 ttl=128 time=26.5 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=5 ttl=128 time=26.10 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=6 ttl=128 time=33.5 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=7 ttl=128 time=27.9 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=8 ttl=128 time=25.3 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=9 ttl=128 time=28.8 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=10 ttl=128 time=33.6 ms

--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 38ms
rtt min/avg/max/mdev = 25.340/29.544/34.586/3.184 ms


检测时间:2020-03-03 11:39:34
PING www.a.shifen.com (183.232.231.172) 56(84) bytes of data.
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=1 ttl=128 time=41.3 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=2 ttl=128 time=29.2 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=3 ttl=128 time=35.3 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=4 ttl=128 time=40.1 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=5 ttl=128 time=28.7 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=6 ttl=128 time=31.7 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=7 ttl=128 time=31.5 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=8 ttl=128 time=27.4 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=9 ttl=128 time=28.6 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=10 ttl=128 time=31.6 ms

--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 40ms
rtt min/avg/max/mdev = 27.359/32.527/41.268/4.609 ms


检测时间:2020-03-03 11:40:43
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=1 ttl=128 time=54.5 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=2 ttl=128 time=31.8 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=3 ttl=128 time=35.2 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=4 ttl=128 time=28.9 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=5 ttl=128 time=37.5 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=6 ttl=128 time=27.4 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=7 ttl=128 time=27.1 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=8 ttl=128 time=28.7 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=9 ttl=128 time=28.5 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=10 ttl=128 time=43.2 ms

--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 35ms
rtt min/avg/max/mdev = 27.140/34.272/54.473/8.343 ms
[root@centos8 ~]#



######

文件/root/3.log自动记录的数据:(以下只是其中连续四次的结果)
[root@centos8 ~]# cat 3.log


检测时间:2020-03-03 11:37:16
PING spool.grid.sinaedge.com (112.48.132.101) 56(84) bytes of data.
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=1 ttl=128 time=50.9 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=2 ttl=128 time=41.10 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=3 ttl=128 time=36.7 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=4 ttl=128 time=39.2 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=5 ttl=128 time=36.3 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=6 ttl=128 time=38.3 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=7 ttl=128 time=41.5 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=8 ttl=128 time=45.2 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=9 ttl=128 time=38.9 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=10 ttl=128 time=36.7 ms

--- spool.grid.sinaedge.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 35ms
rtt min/avg/max/mdev = 36.346/40.564/50.874/4.336 ms


检测时间:2020-03-03 11:38:25
PING spool.grid.sinaedge.com (112.48.132.101) 56(84) bytes of data.
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=1 ttl=128 time=54.9 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=2 ttl=128 time=36.9 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=3 ttl=128 time=48.1 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=4 ttl=128 time=39.5 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=5 ttl=128 time=37.6 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=6 ttl=128 time=42.4 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=7 ttl=128 time=35.5 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=8 ttl=128 time=34.7 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=9 ttl=128 time=39.8 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=10 ttl=128 time=37.9 ms

--- spool.grid.sinaedge.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 37ms
rtt min/avg/max/mdev = 34.662/40.743/54.942/5.987 ms


检测时间:2020-03-03 11:39:34
PING spool.grid.sinaedge.com (112.48.132.101) 56(84) bytes of data.
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=1 ttl=128 time=74.2 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=2 ttl=128 time=78.4 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=3 ttl=128 time=40.2 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=4 ttl=128 time=60.0 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=5 ttl=128 time=40.5 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=6 ttl=128 time=37.2 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=7 ttl=128 time=40.8 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=8 ttl=128 time=36.9 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=9 ttl=128 time=37.9 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=10 ttl=128 time=38.8 ms

--- spool.grid.sinaedge.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 40ms
rtt min/avg/max/mdev = 36.889/48.484/78.438/15.334 ms


检测时间:2020-03-03 11:40:43
PING spool.grid.sinaedge.com (112.48.132.101) 56(84) bytes of data.
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=1 ttl=128 time=58.4 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=2 ttl=128 time=38.8 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=3 ttl=128 time=39.3 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=4 ttl=128 time=39.2 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=5 ttl=128 time=37.4 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=6 ttl=128 time=38.6 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=7 ttl=128 time=42.3 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=8 ttl=128 time=40.2 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=9 ttl=128 time=37.5 ms
64 bytes from 112.48.132.101 (112.48.132.101): icmp_seq=10 ttl=128 time=44.9 ms

--- spool.grid.sinaedge.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 37ms
rtt min/avg/max/mdev = 37.427/41.661/58.398/5.983 ms
[root@centos8 ~]#





相关文章:
Python3使用多进程
CentOS8使用多线程+Ping





#################################
#################################
亲,学习研究也要劳逸结合哦,来我微店逛逛,买点东西好好犒劳犒劳自己和家人吧^_^^_^

苏泊尔多功能电热锅韩式电火锅8-10人家用电炒锅不粘锅电锅电烤锅
guo.png

苏泊尔电火锅多功能家用电热锅不沾锅一体电煮锅宿舍4-6人
huoguo.png

返回列表