ServerDowntimeNotifier/ServerPingService.py
2021-03-10 22:07:52 +01:00

15 lines
269 B
Python

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