Skip to content

Instantly share code, notes, and snippets.

@benfairless
Created April 7, 2016 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benfairless/f0c8de097cc37b9f208450b69a506d82 to your computer and use it in GitHub Desktop.
Save benfairless/f0c8de097cc37b9f208450b69a506d82 to your computer and use it in GitHub Desktop.
#!/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