Skip to content

Instantly share code, notes, and snippets.

@itsderek23
Created May 29, 2012 16:39
Show Gist options
  • Select an option

  • Save itsderek23/2829455 to your computer and use it in GitHub Desktop.

Select an option

Save itsderek23/2829455 to your computer and use it in GitHub Desktop.
Scout's Realtime metrics implementation via Pusher
# Stream data for 20 minutes
while(streamer_start_time+MAX_DURATION > Time.now)
data=[]
# run each scout plugin (cpu usage, apache stats, etc)
plugins.each do |plugin|
plugin.run
data << {
# plugin.reports example data
# [{"Idle %"=>95, "System %"=>1,"User %"=>4}]
:fields=>plugin.reports.inject{|memo,hash|memo.merge(hash)},
:name=> plugin['name']
}
end
bundle={ :hostname=>hostname,
:server_time=>Time.now.strftime("%I:%M:%S %p"),
:data=>data }
# stream the data via pusherapp
Pusher[streaming_key].trigger!('server_data', bundle)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment