操作系统的版本信息:
[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
############
例子一:
[root@centos8 ~]# cat xx.py
- #coding=utf-8
- import _thread
- from time import sleep
- import datetime,os
- def func1(lock):
- dt = datetime.datetime.now()
- tt = dt.strftime('%Y%m%d_%H%M%S')
- Key_t ="\n\n检测时间:" + tt + "\n"
-
- Path_1 = "/root/1.txt"
- f_name = open(Path_1,'a') #写入(追加)具体检测时间到文件
- f_name.write(Key_t)
- f_name.close()
-
- #调用Linux命令
- os.system("ping blog.zhuohua.store -c 10 >> /root/1.txt")
-
- sleep(120) #线程一休眠120秒;各个线程的休眠时间要保持一致
- lock.release()
-
- def func2(lock):
- dt = datetime.datetime.now()
- tt = dt.strftime('%Y%m%d_%H%M%S')
- Key_t ="\n\n检测时间:" + tt + "\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")
-
- sleep(120) #线程二休眠120秒;各个线程的休眠时间要保持一致
- lock.release()
- def func_main():
-
- fields_1 = range(0, 2) # "2" 意味着有2个线程,依此类推
- fields_2 = []
-
- for Key_1 in fields_1:
- Key_1 = _thread.allocate_lock()
- Key_1.acquire()
- fields_2.append(Key_1)
-
- # [0]、[1]代表线程号,依此类推;分别给每个函数的一个变量进行赋值
- _thread.start_new_thread(func1,(fields_2[0],))
- _thread.start_new_thread(func2,(fields_2[1],))
-
- for i in fields_1:
- while fields_2[i].locked():
- pass
-
- if __name__ == '__main__':
- index_1 = 0
- while index_1 < 3: #进程执行3次后自动结束
- func_main()
- index_1 = index_1 + 1
复制代码
脚本运行中的效果:(组合键Ctrl+c可以结束脚本的运行)
######
文件/root/1.txt自动记录的数据:(有三次的Ping结果)
[root@centos8 ~]# cat 1.txt
检测时间:20210302_193113
PING blog.zhuohua.store (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=1 ttl=128 time=18.4 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=2 ttl=128 time=25.2 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=3 ttl=128 time=17.8 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=4 ttl=128 time=17.10 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=7 ttl=128 time=22.4 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=8 ttl=128 time=21.8 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=9 ttl=128 time=16.8 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=10 ttl=128 time=18.9 ms
--- blog.zhuohua.store ping statistics ---
10 packets transmitted, 8 received, 20% packet loss, time 125ms
rtt min/avg/max/mdev = 16.808/19.926/25.199/2.714 ms
检测时间:20210302_193323
PING blog.zhuohua.store (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=1 ttl=128 time=19.8 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=2 ttl=128 time=19.8 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=3 ttl=128 time=20.7 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=4 ttl=128 time=17.4 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=5 ttl=128 time=124 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=6 ttl=128 time=24.3 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=8 ttl=128 time=28.8 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=9 ttl=128 time=18.6 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=10 ttl=128 time=17.9 ms
--- blog.zhuohua.store ping statistics ---
10 packets transmitted, 9 received, 10% packet loss, time 113ms
rtt min/avg/max/mdev = 17.361/32.308/123.532/32.429 ms
检测时间:20210302_193534
PING blog.zhuohua.store (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=1 ttl=128 time=17.3 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=2 ttl=128 time=16.9 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=3 ttl=128 time=19.7 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=4 ttl=128 time=16.10 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=5 ttl=128 time=18.9 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=6 ttl=128 time=17.7 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=7 ttl=128 time=17.8 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=8 ttl=128 time=19.0 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=9 ttl=128 time=17.4 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=10 ttl=128 time=123 ms
--- blog.zhuohua.store ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 48ms
rtt min/avg/max/mdev = 16.914/28.448/122.792/31.460 ms
[root@centos8 ~]#
######
文件/root/2.log自动记录的数据:(所有线程的开始时间都是一样的)
[root@centos8 ~]# cat 2.log
检测时间:20210302_193113
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=128 time=10.8 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=128 time=25.3 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=128 time=10.9 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=4 ttl=128 time=10.8 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=7 ttl=128 time=8.67 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=8 ttl=128 time=9.43 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=9 ttl=128 time=9.25 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=10 ttl=128 time=11.8 ms
--- www.a.shifen.com ping statistics ---
10 packets transmitted, 8 received, 20% packet loss, time 126ms
rtt min/avg/max/mdev = 8.672/12.108/25.303/5.079 ms
检测时间:20210302_193323
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=128 time=10.6 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=128 time=16.4 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=128 time=18.2 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=4 ttl=128 time=12.3 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=5 ttl=128 time=26.7 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=6 ttl=128 time=19.9 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=9 ttl=128 time=9.38 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=10 ttl=128 time=11.3 ms
--- www.a.shifen.com ping statistics ---
10 packets transmitted, 8 received, 20% packet loss, time 134ms
rtt min/avg/max/mdev = 9.377/15.583/26.681/5.503 ms
检测时间:20210302_193534
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=128 time=10.3 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=128 time=8.89 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=128 time=11.5 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=4 ttl=128 time=9.03 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=5 ttl=128 time=9.07 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=6 ttl=128 time=13.5 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=7 ttl=128 time=9.02 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=8 ttl=128 time=12.6 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=9 ttl=128 time=9.73 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=10 ttl=128 time=29.2 ms
--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 47ms
rtt min/avg/max/mdev = 8.890/12.278/29.204/5.849 ms
[root@centos8 ~]#
############
例子二:
[root@centos8 ~]# cat xx.py
- #coding=utf-8
- import _thread
- from time import sleep
- import datetime,os
- def func1(n_sec,lock):
- dt = datetime.datetime.now()
- tt = dt.strftime('%Y%m%d_%H%M%S')
- Key_t ="\n\n检测时间:" + tt + "\n"
-
- Path_1 = "/root/1.txt"
- f_name = open(Path_1,'a') #写入(追加)具体检测时间到文件
- f_name.write(Key_t)
- f_name.close()
-
- #调用Linux命令
- os.system("ping blog.zhuohua.store -c 10 >> /root/1.txt")
-
- sleep(n_sec)
- lock.release()
-
- def func2(n_sec,lock):
- dt = datetime.datetime.now()
- tt = dt.strftime('%Y%m%d_%H%M%S')
- Key_t ="\n\n检测时间:" + tt + "\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")
-
- sleep(n_sec)
- lock.release()
-
- def func3(n_sec,lock):
- dt = datetime.datetime.now()
- tt = dt.strftime('%Y%m%d_%H%M%S')
- Key_t ="\n\n检测时间:" + tt + "\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")
-
- sleep(n_sec)
- lock.release()
- def func_main():
-
- fields_1 = range(0, 3) # "3" 意味着有3个线程,依此类推
- fields_2 = []
-
- for Key_1 in fields_1:
- Key_1 = _thread.allocate_lock()
- Key_1.acquire()
- fields_2.append(Key_1)
-
- # [0]、[1]、[2]代表线程号,依此类推;分别给每个函数的两个变量进行赋值
- # 各个线程的休眠时间要保持一致
- _thread.start_new_thread(func1,(60,fields_2[0])) #线程一休眠60秒
- _thread.start_new_thread(func2,(60,fields_2[1])) #线程二休眠60秒
- _thread.start_new_thread(func3,(60,fields_2[2])) #线程三休眠60秒
-
- for i in fields_1:
- while fields_2[i].locked():
- pass
-
- if __name__ == '__main__':
- while True: #进程会无限次地自动执行下去
- func_main()
复制代码
脚本运行中的效果:(组合键Ctrl+c可以结束脚本的运行)
######
文件/root/1.txt自动记录的数据:(以下只是其中连续四次的结果)
[root@centos8 ~]# cat 1.txt
检测时间:20210302_194318
PING blog.zhuohua.store (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=1 ttl=128 time=18.9 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=2 ttl=128 time=17.2 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=3 ttl=128 time=16.9 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=4 ttl=128 time=18.6 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=5 ttl=128 time=17.5 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=6 ttl=128 time=19.10 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=7 ttl=128 time=20.0 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=8 ttl=128 time=20.3 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=9 ttl=128 time=20.3 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=10 ttl=128 time=16.7 ms
--- blog.zhuohua.store ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 48ms
rtt min/avg/max/mdev = 16.689/18.657/20.339/1.390 ms
检测时间:20210302_194428
PING blog.zhuohua.store (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=1 ttl=128 time=21.10 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=2 ttl=128 time=22.3 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=3 ttl=128 time=17.8 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=4 ttl=128 time=96.4 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=5 ttl=128 time=16.5 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=6 ttl=128 time=20.6 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=7 ttl=128 time=19.7 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=8 ttl=128 time=19.7 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=9 ttl=128 time=20.8 ms
--- blog.zhuohua.store ping statistics ---
10 packets transmitted, 9 received, 10% packet loss, time 60ms
rtt min/avg/max/mdev = 16.469/28.424/96.405/24.098 ms
检测时间:20210302_194538
PING blog.zhuohua.store (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=1 ttl=128 time=18.4 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=2 ttl=128 time=29.1 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=3 ttl=128 time=19.10 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=4 ttl=128 time=18.1 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=5 ttl=128 time=16.10 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=6 ttl=128 time=18.7 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=7 ttl=128 time=22.3 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=8 ttl=128 time=17.2 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=9 ttl=128 time=19.6 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=10 ttl=128 time=19.2 ms
--- blog.zhuohua.store ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 49ms
rtt min/avg/max/mdev = 16.953/19.952/29.066/3.370 ms
检测时间:20210302_194647
PING blog.zhuohua.store (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=1 ttl=128 time=16.10 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=2 ttl=128 time=16.8 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=3 ttl=128 time=17.6 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=4 ttl=128 time=19.3 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=5 ttl=128 time=17.7 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=6 ttl=128 time=18.7 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=7 ttl=128 time=18.6 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=8 ttl=128 time=17.9 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=9 ttl=128 time=17.9 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=10 ttl=128 time=18.9 ms
--- blog.zhuohua.store ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 35ms
rtt min/avg/max/mdev = 16.849/18.044/19.285/0.781 ms
[root@centos8 ~]#
######
文件/root/2.log自动记录的数据:(以下只是其中连续四次的结果)
[root@centos8 ~]# cat 2.log
检测时间:20210302_194318
PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data.
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=128 time=11.1 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=128 time=15.3 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=128 time=11.10 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=4 ttl=128 time=12.6 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=5 ttl=128 time=13.1 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=6 ttl=128 time=10.9 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=7 ttl=128 time=11.6 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=8 ttl=128 time=11.8 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=9 ttl=128 time=10.7 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=10 ttl=128 time=10.5 ms
--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 47ms
rtt min/avg/max/mdev = 10.487/11.950/15.259/1.371 ms
检测时间:20210302_194428
PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data.
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=128 time=17.6 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=128 time=11.5 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=128 time=10.3 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=4 ttl=128 time=90.3 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=5 ttl=128 time=10.8 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=6 ttl=128 time=13.4 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=7 ttl=128 time=13.0 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=8 ttl=128 time=12.8 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=9 ttl=128 time=20.5 ms
--- www.a.shifen.com ping statistics ---
10 packets transmitted, 9 received, 10% packet loss, time 61ms
rtt min/avg/max/mdev = 10.338/22.240/90.334/24.275 ms
检测时间:20210302_194538
PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data.
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=128 time=14.7 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=128 time=25.7 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=128 time=15.4 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=4 ttl=128 time=10.1 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=5 ttl=128 time=10.0 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=6 ttl=128 time=18.5 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=7 ttl=128 time=15.8 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=8 ttl=128 time=11.3 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=9 ttl=128 time=12.6 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=10 ttl=128 time=13.3 ms
--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 49ms
rtt min/avg/max/mdev = 10.011/14.749/25.742/4.452 ms
检测时间:20210302_194647
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=128 time=9.100 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=128 time=11.2 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=128 time=13.5 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=4 ttl=128 time=9.57 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=5 ttl=128 time=9.03 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=6 ttl=128 time=10.2 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=7 ttl=128 time=11.7 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=8 ttl=128 time=10.7 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=9 ttl=128 time=8.83 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=10 ttl=128 time=8.71 ms
--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 45ms
rtt min/avg/max/mdev = 8.714/10.355/13.495/1.427 ms
[root@centos8 ~]#
######
文件/root/3.log自动记录的数据:(以下只是其中连续四次的结果)
[root@centos8 ~]# cat 3.log
检测时间:20210302_194318
PING spool.grid.sinaedge.com (183.60.95.201) 56(84) bytes of data.
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=1 ttl=128 time=12.4 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=2 ttl=128 time=9.65 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=3 ttl=128 time=12.2 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=4 ttl=128 time=9.83 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=5 ttl=128 time=11.6 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=6 ttl=128 time=10.9 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=7 ttl=128 time=9.68 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=8 ttl=128 time=8.64 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=9 ttl=128 time=8.69 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=10 ttl=128 time=9.91 ms
--- spool.grid.sinaedge.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 49ms
rtt min/avg/max/mdev = 8.638/10.351/12.411/1.293 ms
检测时间:20210302_194428
PING spool.grid.sinaedge.com (183.60.95.201) 56(84) bytes of data.
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=1 ttl=128 time=14.7 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=2 ttl=128 time=10.7 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=3 ttl=128 time=9.11 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=4 ttl=128 time=90.4 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=5 ttl=128 time=10.9 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=6 ttl=128 time=13.4 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=7 ttl=128 time=8.21 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=8 ttl=128 time=12.5 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=9 ttl=128 time=20.5 ms
--- spool.grid.sinaedge.com ping statistics ---
10 packets transmitted, 9 received, 10% packet loss, time 60ms
rtt min/avg/max/mdev = 8.212/21.157/90.377/24.710 ms
检测时间:20210302_194538
PING spool.grid.sinaedge.com (183.60.95.201) 56(84) bytes of data.
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=1 ttl=128 time=10.10 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=2 ttl=128 time=19.5 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=3 ttl=128 time=9.08 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=4 ttl=128 time=10.2 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=5 ttl=128 time=8.31 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=6 ttl=128 time=9.53 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=7 ttl=128 time=10.8 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=8 ttl=128 time=8.14 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=9 ttl=128 time=12.6 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=10 ttl=128 time=13.2 ms
--- spool.grid.sinaedge.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 49ms
rtt min/avg/max/mdev = 8.144/11.231/19.459/3.171 ms
检测时间:20210302_194647
PING spool.grid.sinaedge.com (183.60.95.201) 56(84) bytes of data.
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=1 ttl=128 time=10.3 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=2 ttl=128 time=13.3 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=3 ttl=128 time=8.32 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=4 ttl=128 time=14.1 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=5 ttl=128 time=9.68 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=6 ttl=128 time=12.2 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=7 ttl=128 time=9.68 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=8 ttl=128 time=8.31 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=9 ttl=128 time=10.3 ms
64 bytes from 183.60.95.201 (183.60.95.201): icmp_seq=10 ttl=128 time=9.18 ms
--- spool.grid.sinaedge.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 34ms
rtt min/avg/max/mdev = 8.313/10.542/14.050/1.906 ms
[root@centos8 ~]#
相关文章:
Timer/sleep
CentOS6使用Ping
Python3使用多线程/线程锁
CentOS8使用多进程+Ping |