Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save itsderek23/2829464 to your computer and use it in GitHub Desktop.
Scout's Javascript for handling realtime metrics via Pusher
var pusher = new Pusher(appKey,{encrypted: true});
var channel = pusher.subscribe(streamingKey);
channel.bind('server_data', update);
// The function that's called when we retrieve new data from the realtime_data action
function update(server){
// example data
// var server={"hostname": "nuevo.local","data": [{"name": "CPU Usage","fields": {"idle": 95, "system": 1,"user": 4}},{"fields":{"capacity":59.0,"avail":97.0,"size":233.0,"used":136.0},"name":"Disk Usage"}],"server_time": "02:38:11 PM"};
// append data to a smoothie chart
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment