I use htop to view information about the processes currently running in my osx machine, also to sort them by CPU, memory usage, etc.
Is there any way to fetch the output of htop programatically in Ruby?. Also I would like to be able to use the API to sort the processes using various parameters like CPU, memory usage, etc.
I can do IO.popen('ps -a')
and parse the output, but want to know if there is a better way than directly parsing the output of a system command run programmatically.
Check out sys-proctable:
require 'sys/proctable'
Sys::ProcTable.ps
To sort by starttime
:
Sys::ProcTable.ps.sort_by(&:starttime)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With