Skip to content

Instantly share code, notes, and snippets.

@marshyski
Last active August 29, 2015 14:08
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 marshyski/0a12332b1df2524ecf28 to your computer and use it in GitHub Desktop.
Save marshyski/0a12332b1df2524ecf28 to your computer and use it in GitHub Desktop.
Health Check Multiple Puppet Dashboard & PuppetDB with Python Requests
#!/usr/bin/python
import requests
from bs4 import BeautifulSoup
requests.packages.urllib3.disable_warnings()
urls = [
'https://192.168.1.100/nodes/failed?per_page=all',
'https://192.168.1.200/nodes/failed?per_page=all',
]
for URL in urls:
r = requests.get(URL, auth=('timski', 'password'), verify=False)
print r.url, r.headers['Server'], r.status_code
soup = BeautifulSoup(r.text)
td = soup.findAll('td', {'class':'node'}, 'a')
for item in td:
links = item.findAll('a')
for link in links:
print(link.text)
urls = [
'http://192.168.1.101:8080/dashboard/index.html',
'http://192.168.1.201:8080/dashboard/index.html',
]
for URL in urls:
r = requests.get(URL)
print r.url, r.headers['Server'], r.status_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment