Shell script to run command + compare values and post a warning message.

Hi all,

I am trying to create shell script to run command then compare values with rule set for every 5 seconds and post a warning message if the compared value meet the rules.

-the script is related to Oracle/Sun product messaging server 6.2

1) command that need to be run to gather required data for comparison.
/msg2/SUNWmsgsr/sbin -------path to run the command.
./counterutil -o httpstat -------------------------------->this is the command.
Monitor counteroobject (httpstat)
registry /msg2/SUNWmsgsr/data/counter/counter opened
counterobject httpstat opened

count = 1 at 1311142834 rh = 0x4fbf0 oh = 0x4fc18

global.currentstarttime [4 bytes]: 13/May/2011:18:03:04 +0800
global.lastconnectiontime [4 bytes]: 20/Jul/2011:14:20:34 +0800
global.maxconnections [4 bytes]: 931
global.numconnections [4 bytes]: 19272174
global.numcurrentconnections [4 bytes]: 7
global.numcurrentsessions [4 bytes]: 1565 ----> I need to collect this data only
global.numfailedconnections [4 bytes]: 0
global.numfailedlogins [4 bytes]: 10208
global.numgoodlogins [4 bytes]: 2189068

2) compare collected data with rule set.
compare the collected data for every 5 seconds with rule set
-rule details,

if collected data >5800
the server will show popup message or sent the warning to administrator email or something to alert the admin(any idea guys?) : alert message: "Warning current session reaching maximum limit"
else
continue compare

Try:

 
while :
do
/msg2/SUNWmsgsr/sbin/counterutil -o httpstat | awk -F"[:]" '/global.numcurrentsessions/ { print $NF; }' | read var
[[ $var -gt  5800 ]] && mailx -s "alert :Max connections " -c "admin@abc.com" 
sleep 5
done

okay ill try