I'm trying to write a little script and having trouble comparing integers and
decimal numbers. The shell doesn't like it and I haven't been able to figure
out how to get around it. Script is named zyx.
1 #!/bin/sh
2 ADMINA="[email protected]"
3 dt=`date '+%a %b %e %I:%M %p' `
4 svr=`hostname`
5 ALERT=75
6 mpstat | grep -i all |awk '{print $4}'|
7 while read output;
8 do
9 cpuutil=`(echo $output | awk '{ print $1}' | cut -d'%' -f1 )`
10 set -x
11 if [ "$cpuutil" -ge $ALERT ]; then
12 echo "CPU utilization has risen beyond the alert threshold on $svr
at $dt"| mail -vs "Alert:- CPU utilization is hi gh on $svr at $dt"
$ADMINA
13 fi
14 done
xyz
+ '[' 3.19 -ge 75 ']'
/usr/sbin/xyz: line 11: [: 3.19: integer expression expected
+ read output
mpstat is returns 3.19 and I'm trying, on line 11, to compare that to ALERT
which is set to 75. I think I need to strip off the decimal part of 3.19 but
haven't found any way to do it.
Bobby Bauer
Center for Information Technology
National Institutes of Health
Bethesda, MD 20892-5628
301-594-7474
----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
----------------------------------------------------------------------
For more information on Linux on System z, visit
http://wiki.linuxvm.org/