Linux: Get CPU Usage in percent

//Linux: Get CPU Usage in percent

Linux: Get CPU Usage in percent

Hi there,

Here is how to get the linux CPU usage taken on a weighed across all CPU’s.

 

top -b2 -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 }'

 

/Renzo

 

By |2017-03-20T11:58:00+00:00March 20th, 2017|Linux|Comments Off on Linux: Get CPU Usage in percent