I am currently using the below method to extract CPU usage idle value from top command and subtracting the value from 100. Is this method correct and is there a better way to achieve the same.
Also, my linux VM is a stripped down version and has only few basic tools like top
. Installing other tools is not an option as the package manager is also removed.
CPU_IDLE="$(top -bn2 | grep -F '%Cpu' | tail -n 4 | gawk '{print $8 $9}' | tr -s '\n\:\,[:alpha:]' ' '| gawk '{print $2}'),"
deb
package and copy files manually, or compile from source code. – Michael D. Apr 12 '17 at 10:11