Guest User

Untitled

a guest
Nov 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. import os
  2.  
  3. # Read IP's from a list
  4. IP_ADDR = ['192.168.1.1', '192.168.1.201', '192.168.1.202', '192.168.1.203',
  5. '192.168.1.204', '192.168.1.205', '192.168.1.206',
  6. '192.168.1.207', '192.168.1.208', '192.168.1.209',
  7. '192.168.1.210', '192.168.1.211', '192.168.1.212',
  8. '192.168.1.213', '192.168.1.214', '192.168.1.215']
  9.  
  10. IP_OWNER = ['Classroom Server', 'Kristian','Helge Sverre',
  11. 'Eirik','NA','NA','NA','NA',
  12. 'NA','NA','NA','NA','NA','NA','NA','NA']
  13.  
  14. # Blank list, use append to populate list
  15. IP_STATE = []
  16.  
  17. # use this so check the length of the list, instead of guessing it
  18. list_length = len(IP_ADDR)
  19.  
  20. # grab the username of the user, not really nessecary
  21. username = os.getlogin()
  22.  
  23. print "\nWelcome " + username
  24.  
  25. # os.system ping return codes: 256 is failed, 2 is cancled, 0 is successful
  26. # ping the servers.
  27. # remove COMMAND to show the ping info, hidden by default
  28. for iii in range(0,list_length):
  29. if os.system("ping " + IP_ADDR[iii] + " -c 1 -w 1") == 0:
  30. # add the IP state to the IP_STATE list
  31. IP_STATE.append("Up")
  32. else:
  33. # Add the IP state to the IP_STATE list
  34. IP_STATE.append("Down?")
  35.  
  36. iii = 0
  37.  
  38. # Give the user a clue what is what
  39. print "IP Address\t Status\t Operator\n---------------------------------------------------"
  40.  
  41. # Show information
  42. for iii in range(0,list_length):
  43. print IP_ADDR[iii] + "\t - " + IP_STATE[iii] + "\t - " + IP_OWNER[iii]
Add Comment
Please, Sign In to add comment