|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 jitianmoshen 于 2020-11-22 09:57 编辑
谁帮我看看怎么改,谢谢
- def ping_IP(IP_QUEUE):
- count_true = 0
- while not IP_QUEUE.empty():
- ip = IP_QUEUE.get().strip('\n')
- # print (ip)
- res = subprocess.call(f"ping -w 1000 -n 1 {ip}", stdout=subprocess.PIPE, shell=True)
- # print (res)
- today = datetime.datetime.now().strftime("%Y年%m月%d日%H:%M:%S")
- if res == 0:
- count_true += 1
- h = subprocess.getoutput(f"Ping {ip}")
- # print (h)
- if 'TTL=' in h:
- if "Average" in h:
- res = f"网络可以正常连通,平均延时 = {h.split('Average = ')[1]}"
- logging.info(f"{today} IP = {ip} {res}")
- elif "平均" in h:
- res = f"网络可以正常连通,平均延时 = {h.split('平均 = ')[1]}"
- logging.info(f"{today} IP = {ip} {res}")
- else:
- res = f"网络可以正常连通."
- logging.info(f"{today} IP = {ip} {res}")
- #else:
- #res = '网络连接失败!\n'
- #print(res)
- print(count_true)
- logging.info(f"一共ping通 {count_true} 个ip.")
复制代码 |
|