Created
May 29, 2012 16:39
-
-
Save itsderek23/2829455 to your computer and use it in GitHub Desktop.
Scout's Realtime metrics implementation via Pusher
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
| # 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