Last active
August 29, 2015 14:25
-
-
Save ssplatt/8ba50b6dcdaec5969d2b to your computer and use it in GitHub Desktop.
ganglia cpu user graph in 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' | |
# cpu_user url | |
uri_cpu = Addressable::URI.escape "http://localhost/ganglia/graph.php?r=hour&title=&vl=&x=&n=&hreg[]=compute&mreg[]=cpu_user>ype=stack&glegend=hide&aggregate=1&embed=1&_=1410463742829&json=1" | |
SCHEDULER.every '15s', :first_in => 0 do |job| | |
points = [] | |
response = HTTParty.get(uri_cpu) | |
response.each do |host| | |
step = 0 | |
host["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_cpu', { points: points }) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment