Wiki‎ > ‎

Real CPU Load

posted Sep 30, 2016, 10:33 PM by Dong Xu   [ updated Oct 1, 2016, 8:23 PM ]
top -b -n2 -p 1 | fgrep "Cpu(s)" | tail -1 | awk -F'id,' -v prefix="$prefix" '{ split($1, vs, ","); v=vs[length(vs)]; sub("%", "", v); printf "%s%.1f%%\n", prefix, 100 - v }'

or

sar  1 1
sar  1 3  (3 sec avg)
sar -P ALL 1 1  (all cores)

sysstat package required

Comments