ServerDowntimeNotifier/ServerPingService.py

15 lines
269 B
Python
Raw Normal View History

2021-03-10 21:07:52 +00:00
import ping3
def ping(host: str) -> int:
"""
Pings the given host and returns the time the ping took ins ms or -1 if the ping was not successful
:param host:
:return:
"""
res = ping3.ping(dest_addr=host, unit='ms')
if res:
return int(res)
else:
return -1