Created
March 5, 2015 02:31
-
-
Save jaimegago/c7e15a740c3b874a1ff5 to your computer and use it in GitHub Desktop.
Python script to create and download PNG graphs via Graphite Render URL API
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/python -tt | |
import requests | |
graphite_targets = [ | |
'some.graphite.metric.target', | |
'another.graphite.metric.target | |
] | |
graphite = 'some_graphite_host' | |
render_url = 'http://%s/render/' % (graphite) | |
params = { | |
'width' : 800, | |
'heigth' : 600, | |
'format' : 'png' | |
} | |
for graphite_target in graphite_targets: | |
params['target'] = graphite_target | |
response = requests.get(render_url, params=params) | |
png_file_path = "/tmpt/%s.png" % graphite_target | |
png_file = open(png_file_path, "wb") | |
png_file.write(response.content) | |
png_file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment