Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- # Read IP's from a list
- IP_ADDR = ['192.168.1.1', '192.168.1.201', '192.168.1.202', '192.168.1.203',
- '192.168.1.204', '192.168.1.205', '192.168.1.206',
- '192.168.1.207', '192.168.1.208', '192.168.1.209',
- '192.168.1.210', '192.168.1.211', '192.168.1.212',
- '192.168.1.213', '192.168.1.214', '192.168.1.215']
- IP_OWNER = ['Classroom Server', 'Kristian','Helge Sverre',
- 'Eirik','NA','NA','NA','NA',
- 'NA','NA','NA','NA','NA','NA','NA','NA']
- # Blank list, use append to populate list
- IP_STATE = []
- # use this so check the length of the list, instead of guessing it
- list_length = len(IP_ADDR)
- # grab the username of the user, not really nessecary
- username = os.getlogin()
- print "\nWelcome " + username
- # os.system ping return codes: 256 is failed, 2 is cancled, 0 is successful
- # ping the servers.
- # remove COMMAND to show the ping info, hidden by default
- for iii in range(0,list_length):
- if os.system("ping " + IP_ADDR[iii] + " -c 1 -w 1") == 0:
- # add the IP state to the IP_STATE list
- IP_STATE.append("Up")
- else:
- # Add the IP state to the IP_STATE list
- IP_STATE.append("Down?")
- iii = 0
- # Give the user a clue what is what
- print "IP Address\t Status\t Operator\n---------------------------------------------------"
- # Show information
- for iii in range(0,list_length):
- print IP_ADDR[iii] + "\t - " + IP_STATE[iii] + "\t - " + IP_OWNER[iii]
Add Comment
Please, Sign In to add comment