gon.watch with unix top sample - gazay/gon GitHub Wiki
Fun sample how you easily can display on web page your servers top
in real time:
app/controllers/home_controller.rb
def top
gon.watch.top = `top -l1`
end
app/views/layouts/application.html.erb
<head>
<title>GonTest326</title>
<%= include_gon :watch => true %>
app/views/home/top.html.erb
<pre id='top' style='font-family:monospace;'></pre>
config/routes.rb
get '/top' => 'home#top'
app/assets/javascripts/home.js.coffee
$(document).ready ->
renewTop = (data) ->
$('#top').text(data.replace(/\\n/g, "\n"))
gon.watch('top', interval: 1000, renewTop)