I'm trying to create a simple script that takes an average load percentage of the CPU each minute. I'm doing this by using the sar
command from the sysstat
package.
Here is my current code:
#!/bin/bash
sar -u 1 10 | grep Average > /custom/tmp/idlefile
idleval=`awk '{print $8}' /custom/tmp/idlefile`
rm /custom/tmp/idlefile
rm -rf /custom/idlepercentage/*
touch /custom/idlepercentage/$idleval
exit 0
The problem is, the only thing it can do right now is output an idle percentage. I'd like it to simply output a load percentage.
I attempted to do this by:
loadval=100.00-`echo $idleval`
but it shouts at me and won't do what I ask it to do.
It seems like it wont do the basic arithmetic to do 100% - idle percent to give load percent.