m1/mping.py
2020-04-17 16:37:08 +08:00

19 lines
355 B
Python

#!/usr/bin/python
# -*- coding:utf-8 _*-
"""
@author: pengtao
@file: mping.py
@time: 2020/03/26
"""
from .common import run_cmd
def test_ping(ip):
cmd = f"ping {ip} -c 1 -s 1 -W 1 | grep '100% packet loss'|wc -l"
status, out = run_cmd(cmd)
if status and out.decode().strip() == '0':
return True
else:
return False