0

hello i want to create a ping script on python where it will ping 3 ips and give me out only the result if the server is alive i want to give me the packet loss and generate if the ms time is less than 100 . I have no pythong expert skills

user6367569
  • 43
  • 1
  • 9

1 Answers1

0

Just Change the hostname with List and provide the ip address in the code given in the another StackOverflow thread

Check out this

Sample Code

import subprocess
hosts = ['link1','link2','link3']
for host in hosts:
    result = subprocess.check_output("ping google.com")
    print result
    # do some process on result 
Community
  • 1
  • 1
Vardhman Patil
  • 517
  • 6
  • 22
  • what about the time and the packet loss? will be listed after executing that code? because i want it to give the pack met losss result and the ms time – user6367569 Oct 04 '16 at 14:51
  • is there any way to print the result value in a text file? – user6367569 Oct 05 '16 at 17:57
  • see you have to do processing on result and extract whatever information you are looking for.You can use Regex https://docs.python.org/2/library/re.html . If you want to do continuous monitoring then better way you use Threads. – Vardhman Patil Jun 26 '17 at 14:09