I'm trying to get the CPU's total load with this:
IDLE=$(mpstat | grep "all" | cut -c 92-)
CPULD=$(expr 100 - $IDLE)
echo $CPULD
but it always returns:
expr: non-integer argument on the second line.
I've looked around and everyone says that integers will be automatically recognized in strings, but it doesn't seem to be working.
EDIT: For those of you who wish to see my full and now-working script, it is here: http://pastebin.com/cFQzz4Up
mpstat | grep "all" | cut -c 92-
?mstat
but my tests and its manpage seem to suggest that it gives the average over the entire time the machine has been on and not the current CPU use.