Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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