Created
April 7, 2016 16:09
-
-
Save benfairless/f0c8de097cc37b9f208450b69a506d82 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import requests | |
import yaml | |
with open('./config.yaml','r') as f: | |
config = yaml.load(f.read()) | |
# Returns boolean based on exit status | |
def checkhealth(url): | |
response = {} | |
try: | |
check = requests.get(url,timeout=5) | |
response['status'] = check.status_code | |
response['content'] = check.text | |
except requests.exceptions.ConnectionError: | |
response['status'] = 504 | |
response['content'] = 'Unable to connect' | |
return response | |
def loop(config): | |
for item in config: | |
check = checkhealth(item['url']) | |
print(item['name'],check) | |
loop(config) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment