Last active
August 29, 2015 14:08
-
-
Save marshyski/0a12332b1df2524ecf28 to your computer and use it in GitHub Desktop.
Health Check Multiple Puppet Dashboard & PuppetDB with Python Requests
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/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