OSX doesn't have procfs, so grabbing cpu usage from /proc/stat won't
work.
Rather, if is_osx() returns true, get stats from the output of the
iostat utility.
Note that the first line of data that iostat prints is always averaged
over system uptime. You need to tell it to print two lines, averaging
over one second, and use the data in the second line.
OSX doesn't have procfs, so grabbing cpu usage from /proc/stat won't work.
Rather, if is_osx() returns true, get stats from the output of the iostat utility.
Note that the first line of data that iostat prints is always averaged over system uptime. You need to tell it to print two lines, averaging over one second, and use the data in the second line.