On Wed, Mar 26, 2003 at 12:05:56PM -0800, Chris wrote:
> Jeff,
> 
> Thanks!!
> 
> I sort of got it working, other than it complains with "integer expression
> expected" on the "if [ $load -gt $#MY_THRESHOLD ] ; then".  If I comment out
> the whole loop and have it send the current CPU level by itself, without
> checking MY_THRESHOLD, it works perfectly...  one time only, of course.
> 
> Is there a trick to forcing it into treating MY_THRESHOLD as an integer?
> Perhaps have to multiply it by 100 to get a full integer, rather than a
> decimal value...?  If so... how?  :-)  (yes, I'm a newbie)

Yes - multiply by 100 would be fine - 
Just remember you have to multiply both values.

how - heh, heh, heh....  Well , you can do it with a sed script.

Time to read the bash man page....

And as always - theres more than one way to do it.

hmm - does shell math work on floats ? Nope.

But if we assume that loadavg numbers ALWAYS have two digits to the 
right of the decimal point then an edit script can do the job for us.
Its not elegant but it may work.....

load=`cat /proc/loadavg | awk '{print $1}' | sed -e 's/\.//'`

may work.... 

> 
> Chris
> 
> 
> 
> ----- Original Message -----
> From: "Jeff Kinz" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, March 26, 2003 11:31 AM
> Subject: Re: CPU monitoring service => even more Correct
> 
> 
> > On Wed, Mar 26, 2003 at 02:25:52PM -0500, Jeff Kinz wrote:
> > CORRECTION:
> >   mail  -s "$NAME load is at $load"   [EMAIL PROTECTED]
> > should be :
> >   mail  -n -s "$NAME load is at $load" [EMAIL PROTECTED] <
> /dev/null
> >
> > resulting in.:
> >
> >
> > #The name of the server
> > NAME=`hostname`
> >
> > #  Maximum load you want to allow
> > MY_THRESHOLD="0.5"
> >
> > # of seconds to wait between load checks.
> > SECONDS=5
> >
> > # Loop almost forever.
> > while (`true`) ; do
> >
> > # Replace $1 with which ever field of loadavg you want.
> > load=`cat /proc/loadavg | awk '{print $1}'`
> >
> > if [ $load -gt $#MY_THRESHOLD ] ; then
> >   mail  -n -s "$NAME load is at $load" [EMAIL PROTECTED] <
> /dev/null
> >
> > # If we stay in this loop you'll get a TON of emails
> > on your cell phone.
> > exit
> > fi
> > sleep $SECONDS
> > done
> >
> >
> >
> > --
> > Jeff Kinz, Open-PC, Emergent Research,  Hudson, MA.  [EMAIL PROTECTED]
> 
> 
> 
> 
> -- 
> redhat-list mailing list
> unsubscribe mailto:[EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/redhat-list
> 

-- 
Jeff Kinz, Open-PC, Emergent Research,  Hudson, MA.  [EMAIL PROTECTED]
copyright 2003.  Use is restricted. Any use is an 
acceptance of the offer at http://www.kinz.org/policy.html.



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to