Last active
August 29, 2015 14:25
-
-
Save ssplatt/1a5cbf9964971eaf6d40 to your computer and use it in GitHub Desktop.
ganglia mem data to dashing
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
require 'httparty' | |
require 'addressable/uri' | |
uri = Addressable::URI.escape "graph.php?r=hour&c=Cluster&m=load_one&s=by+name&mc=2&g=mem_report&json=1" | |
SCHEDULER.every '15s', :first_in => 0 do |job| | |
points = [] | |
response = HTTParty.get(uri) | |
response.take(4).each do |data| | |
step = 0 | |
data["datapoints"].each do |val,secs| | |
if val == "NaN" | |
next | |
end | |
if points[step] == nil | |
# -14400 for EST | |
points << { x: secs-14400, y: val.round } | |
else | |
points[step][:y] += val.round | |
end | |
step += 1 | |
end | |
end | |
send_event('ganglia_mem', { points: points }) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment