Logic for alert scripts.

Hello,
In my system, I have implemented various alerts.
An example:

#!/bin/sh
BILL=bill@company.com
#GETS THE CURRENT NO OF SESSIONS OPENED IN ORACLE
SESSION_NO=`sqlplus -s ${TEST_USER} <<EOF
SET HEAD OFF
@/home/alerts/vlib/cur_session_no.sql
EOF`
 
#MANUALLY SET A THRESHOLD FOR THE SESSONS
SESSION_THRESHOLD=300
 
MAX_SESSIONS=`sqlplus -s ${TEST_USER} <<EOF
SET HEAD OFF
@/home/alerts/vlib/max_session_no.sql
EOF`
 
#IF NO OF SESSIONS EXCEED THE THRESHOLD SEND ME AN EMAIL
if [ $SESSION_NO -gt $SESSION_THRESHOLD ];
then
mailx -s "Number of processes in $ORACLE_SID Critical" $BILL <<EOF
Current No. of sessions in $ORACLE_SID: $SESSION_NO
Max No. of sessions are $MAX_SESSIONS
EOF
fi
exit

And these alerts are scheduled hourly.
My problem is that untill the problem is solved, it keeps sending the mail every hour.

Please give my any ideas (logic) on how I can have the alerts send to me once.
e.g use a flag that I will manually delete when the problem is resolved ?

Any ideas welcomed

Thank you in advance for your help.

---------- Post updated at 12:01 PM ---------- Previous update was at 11:50 AM ----------

I am thinking of:
1)Send the email once,
2)if the check (if [ $SESSION_NO -gt $SESSION_THRESHOLD ];
) does not change do not send the mail again.
3) When problem solved (check fails)
reenable the alert mechanism.

yes, store the $session_no in one file and retrieve it and check with the current value. if differs, then go for email, otherwise dont triggger the email

1 Like