Skip to content

Instantly share code, notes, and snippets.

@ssplatt
Last active August 29, 2015 14:25
Show Gist options
  • Save ssplatt/1a5cbf9964971eaf6d40 to your computer and use it in GitHub Desktop.
Save ssplatt/1a5cbf9964971eaf6d40 to your computer and use it in GitHub Desktop.
ganglia mem data to dashing
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