Created
October 2, 2013 20:52
-
-
Save iign/6800372 to your computer and use it in GitHub Desktop.
Simple site monitor.
Gets urls from text file and checks http status code for each.
This file contains hidden or 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
#!/usr/bin/env | |
import httplib | |
file_list = open('sites.txt', 'r') | |
def check_site(url): | |
conn = httplib.HTTPConnection(url) | |
try: | |
conn.request("HEAD", "/") | |
except Exception, e: | |
return None | |
else: | |
response = conn.getresponse() | |
return response | |
lines = file_list.readlines() | |
print lines | |
for site_url in lines: | |
print site_url | |
site = check_site(site_url.strip()) | |
print site_url + ' status: ', site.status, site.reason | |
if site.status > 400: | |
print 'ERROR. Notify.' | |
file_list.close() |
This file contains hidden or 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
google.com | |
example.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment