This is working for me in windows. Although I just realized the OP asked for response time too. @c.bertulli looks like he has the best answer.
import os
def ping(ip):
return os.system("ping " + ip) == 0
print ping("8.8.8.8")
print ping("1.2.3.4")
print ping("4.4.4.4")
If you are running in Unix you’ll need to change the first part of the os.system call to ping -c 5
to limit the number of ping attempts.
This should print out the results of the command and also return a boolean value for each function call. Results should be True, False, False