Thanks John, worked perfectly. Can you explain a little what /%.*/ is doing or 
tell me what it is so I can do some reading.

Bobby Bauer
Center for Information Technology
National Institutes of Health
Bethesda, MD 20892-5628
301-594-7474



-----Original Message-----
From: McKown, John [mailto:[email protected]] 
Sent: Wednesday, December 08, 2010 2:59 PM
To: [email protected]
Subject: Re: Need a little help with a Linux script

if [ ${cpuutil/%.*/} -ge 75 ]; then

will drop the . and everthing after in ${cpuutil} if you're using BASH.

--
John McKown 
Systems Engineer IV
IT

Administrative Services Group

HealthMarkets(r)

9151 Boulevard 26 * N. Richland Hills * TX 76010
(817) 255-3225 phone * 
[email protected] * www.HealthMarkets.com

Confidentiality Notice: This e-mail message may contain confidential or 
proprietary information. If you are not the intended recipient, please contact 
the sender by reply e-mail and destroy all copies of the original message. 
HealthMarkets(r) is the brand name for products underwritten and issued by the 
insurance subsidiaries of HealthMarkets, Inc. -The Chesapeake Life Insurance 
Company(r), Mid-West National Life Insurance Company of TennesseeSM and The 
MEGA Life and Health Insurance Company.SM

 

> -----Original Message-----
> From: Linux on 390 Port [mailto:[email protected]] On 
> Behalf Of Bauer, Bobby (NIH/CIT) [E]
> Sent: Wednesday, December 08, 2010 1:41 PM
> To: [email protected]
> Subject: Need a little help with a Linux script
> 
> 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/
> 
> 
----------------------------------------------------------------------
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/

----------------------------------------------------------------------
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/

Reply via email to