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})

In reply to Re: How do I calculate the current CPU usage? by andreas1234567
in thread How do I calculate the current CPU usage? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.