Logic for alert scripts.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Logic for alert scripts.
# 1  
Old 08-24-2011
Logic for alert scripts.

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

Code:
#!/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.
# 2  
Old 08-24-2011
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
This User Gave Thanks to itkamaraj For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl scripts: requesting for logic explanation

Hi, balajesuri and durden_tyler, I have found your perl script for the thread https://www.unix.com/shell-programming-scripting/176370-perl-script-help-me-extracting-string.html, but find it difficult to understand the syntax. Could you or any forum members kindly shed some light on the logic... (3 Replies)
Discussion started by: royalibrahim
3 Replies

2. Shell Programming and Scripting

Help with Logic - Copying the same files by 2 Linux scripts to same directory

Hi All, Good Morning ! Can anyone help me understand the following scenario. Scenario 1 : 2 LINUX Scripts(Process 1 & 2) are trying to copy the same file (lets call it FileA.txt) to the same directory (lets say, /home/abc/zyz) at the same time. If both copy is happening at the same... (9 Replies)
Discussion started by: dsfreddie
9 Replies

3. Emergency UNIX and Linux Support

Logic of 3 scripts and 1 header

Hi, I am hitting my head for weeks now, I run 3 sites that are basically serving 1 community, a job search, a wiki and a social networking platform. Rather than promote all three I want to create the illusion that its all 1 website, and I identify 3 areas to make this possible. 1) unified... (7 Replies)
Discussion started by: lawstudent
7 Replies
Login or Register to Ask a Question