In linux, I can get the current CPU usage from /proc/stat ; is there an OSX equivalent? Or some kind of utility that returns easily parsed and consistent output? I need this in a Ruby program.
/proc/stat
sysctl easy to parse; you can get the average load value by checking the vm.loadavg value.
sysctl
vm.loadavg
$ sysctl vm.loadavg vm.loadavg: { 0.57 0.80 0.85 }
There are several ways, all I know rely on command line tools:
$
top
system_profiler
$ iostat -1
If you want parsing efforts to be low, try reducing the result by applying useful options to the tools.