Created
August 6, 2013 17:50
-
-
Save adammelancon/6166805 to your computer and use it in GitHub Desktop.
A simple python script to ping a few branch locations and return the status.
It's for the Windows ping command, but could be edited easily for Linux.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import os | |
branches = { | |
'192.168.2.1':'Branch1', | |
'192.168.3.1':'Branch2', | |
'192.168.9.1':'Branch3', | |
'192.168.5.1':'Branch4', | |
'192.168.6.1':'Branch5', | |
'192.168.12.1':'Branch6', | |
'192.168.7.1':'Branch7', | |
'192.168.14.1':'Branch8', | |
'192.168.15.1':'Branch9', | |
'192.168.16.1':'Branch10', | |
'192.168.8.1':'Branch11', | |
'192.168.21.1':'Branch12', | |
'192.168.23.1':'Branch13', | |
'192.168.24.1':'Branch14', | |
'192.168.22.1':'Branch15'} | |
results = [] | |
for ip in branches.keys(): | |
res = subprocess.call(['ping', '-n', "1", ip]) | |
if res == 0: | |
results.append("Ping to" + " " + branches[ip] + " " + "OK") | |
elif res == 2: | |
results.append("No response from" + " " + branches[ip]) | |
else: | |
results.append("Ping to" + " " + branches[ip] + " " + "FAILED!") | |
os.system('cls') | |
for i in results: | |
print i | |
print " " | |
raw_input("Hit Enter to exit") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment