Skip to content

Instantly share code, notes, and snippets.

@EmmanuelOga
Created May 5, 2010 04:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save EmmanuelOga/390396 to your computer and use it in GitHub Desktop.
def read_cpu_load
`ps -p #{$$} -o pcpu`.split.last.strip
end
require 'eventmachine'
module Simple
def receive_data data
puts data
end
def unbind
puts "ruby died with exit status: #{get_status.exitstatus}"
end
end
EM.run{
EventMachine::PeriodicTimer.new(1) do
puts "\n#{read_cpu_load}\n"
end
EM.popen("cat fs/event", Simple)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment