read data from a stream in ruby
I have to run top
in my machine (mac osx), and get the cpu usage from there, in real 开发者_如何学Ctime.
How can I do that?
Thank you.
The -n command line option lets you run top for the specified number of cycles, then exit. So top -n 1
just runs it once and you can parse the output.
精彩评论