in reply to How do I calculate the current CPU usage?

You did not mention your platform. vmstat reports (amongst other things) percentages of total CPU time:
$ vmstat -n 1 procs -----------memory---------- ---swap-- -----io---- --system-- --- +-cpu---- r b swpd free buff cache si so bi bo in cs us +sy id wa 1 0 160 84600 330848 251724 0 0 74 102 1 0 8 + 2 90 0 0 0 160 84600 330848 251724 0 0 0 0 1018 337 1 + 0 99 0 0 0 160 84600 330848 251724 0 0 0 160 1011 343 3 + 0 97 0 0 0 160 84600 330848 251724 0 0 0 0 1019 351 1 + 0 99 0 0 0 160 84608 330848 251724 0 0 0 0 1003 344 2 + 0 98 0
--
print map{chr}unpack(q{A3}x24,q{074117115116032097110111116104101114032080101114108032104097099107101114})

Replies are listed 'Best First'.
Re^2: How do I calculate the current CPU usage?
by Anonymous Monk on Jun 21, 2007 at 06:10 UTC
    This is close enough to what I needed. Thanks!