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)
The problem is that $load actually contains a string representation of a floating point number, complete with decimal point. Bash only supports integer math. It will handle a string representation of an interger as an integer in the correct context (similar to perl) but it will balk at attempting to handle strings that look like floating point numbers.
Try this:
# Get the real load.
trueload=$(cat /proc/loadavg | awk '{print $1}')# Multiply the load by 100 to create an integer, # then keep only the stuff in front of the decimal point. load=$(echo "$trueload * 100" | bc | cut -f 1 -d .)
# See if the load is too high. if [ $load -gt $MY_THRESHOLD ] ; then ... do stuff
Tony -- Anthony E. Greene <mailto:[EMAIL PROTECTED]> OpenPGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26 C484 A42A 60DD 6C94 239D AOL/Yahoo Chat: TonyG05 HomePage: <http://www.pobox.com/~agreene/> Linux. The choice of a GNU generation. <http://www.linux.org/>
-- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list
