I need to ping IPs and return 2 pieces of info: success and average ping time.
Using the pythonping module I figure I can determine success if packets lost == 0 then it succeeded. Please let me know if I'm wrong or if there's a better way.
As for getting the average ping time, I'm lost on this. If you know, please let me know. Thanks.
Here's what I have.
Thanks.
from pythonping import ping
# The IP, Timeout Seconds
result = ping('2.255.250.65', count=1)
print('result.packets_lost ' + str(result.packets_lost))
if result.packets_lost == 0:
print('success')
# Need to get the average ping time here
print(avg ping time)
else:
print('failed')
print(-1)