Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. #coding: utf8
  2.  
  3. import os
  4. hostname = "192.168.12.167" #host 1.3
  5. response = os.system("ping -c 1  " + hostname)
  6. #and then check the response...
  7.  
  8. if response == 0:
  9.   hostname = "192.168.210.10"   # host 1.1
  10.   response = os.system("ping -c 1 " + hostname)
  11. #  print (ho, 'is down!')
  12.  
  13. if response != 0:
  14. #  print (hostname, 'is down!')
  15.   hostname = "192.168.100.2"   # host 1.2
  16.   response = os.system("ping -c 1  " + hostname)
  17.  
  18. if response != 0:
  19.   print (hostname, 'is down!')
  20. # выполняем код 1.3
  21.  
  22. else:
  23. # проверя
  24.   hostname = "192.168.100.3"
  25.   response = os.system("ping -c 1  " + hostname)
  26.  
  27.  
  28. if response == 0:
  29.   hostname = "192.168.10.110" #example
  30.   response = os.system("ping -c 1  " + hostname)
  31.  
  32. if response != 0:
  33.   hostname = "192.168.11.110" #example
  34.   response = os.system("ping -c 1  " + hostname)
  35.  
  36. if response != 0:
  37.   print (hostname, 'is up!')
  38.  
  39. else:
  40. #  hostname = "1.1.1.1.1"
  41.     print (hostname, 'is down!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement