I'm a newbie to Linux shell scripting. I have this script but I can't get one portion of the script to work. This script is supposed to email me everytime the cpu number reach 90 or above. The issue is, its comparing to a decimal and its not functioning as it should. Can you all please advise:
#!/bin/ksh
top -b -n 1 |head -8 >/tmp/cpu.txt
sed -e '1,5d' /tmp/cpu.txt >/tmp/cpu2.txt
Test_CPU=`cat /tmp/cpu2.txt|tail -1|awk '{print $9}'`
host=`hostname`
if [ $Test_CPU -gt 90 ];
then
mail -s "Test CPU USE on $host" email@whatever.com < /tmp/cpu2.txt
fi
exit
I'm receiving the below error message: test.sh: line 6: [: 78.9: integer expression expected
I have tried using if [ $High_CPU > 90 ];
I receive the error test.sh: line 6: 90.0: command not found
Please help.