Run the script continously but mail once in 1 hour


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run the script continously but mail once in 1 hour
# 1  
Old 12-16-2014
Run the script continously but mail once in 1 hour

Hi,
I have a script written for monitoring the queue manager status continously. below is the script.
Code:
QMGR=`dspmq | awk '{print $1}' | cut -f2 -d "(" |  cut -f1 -d ")"`
QMSTATUS=`dspmq | awk '{print $2}' | cut -f2 -d "(" |  cut -f1 -d ")"`
count=`dspmq | awk '{print $1}' | cut -f2 -d "(" |  cut -f1 -d ")"|wc -l`
while [ $count -ne 0 ]
do
e=`echo $QMGR | cut -f$count -d" "`
f=`echo $QMSTATUS | cut -f$count -d" "`
if [ $f != "Running" ]
then
echo "$e is not running" >> /var/mqm/ILhousekeeping/QMdown.txt
fi
count=`expr $count - 1`
done
mail -s "Queue Manager down - `hostname` - $e" anusha1234@gmail.com < /var/mqm/ILhousekeeping/QMdown.txt

The requirement is, this script has to run continuously (Configured in Cron) to monitor the queue manager status, but the mail has to be triggered only once in one hour if the Queue manager is down.

Thanks,
Anusha
This User Gave Thanks to Anusha M For This Post:
# 2  
Old 12-16-2014
Don't run that script "continuously"; it will be an enormous waste of resources at no benefit. Think about what is an adequate reaction time (one hour looks good according to your mail frequency) and schedule accordingly. It doesn't seem like you gain anything in running it more often.
# 3  
Old 12-16-2014
Hi Rudic,
The problem is if I configure the script to run every one hour, in between time if the queue manager is down I will not be notified, which can cause issue.

The script has to run continuously, if the queue manager is down it has to send mail immediately and next mail notification has to be sent after an hour (In case if the Queue manager is still down)

Thanks,
Anusha
# 4  
Old 12-16-2014
Anusha,

RudiC is correct, continuously checking if the queue manager is down would waste resources for little benefit. And email is not a good choice (imho) for "instant" notification - it is neither deterministic nor reliable as it requires someone to notice that a message has been delivered to an email client. Or to notice that a message has not been delivered.

What O/S and version are you running on?

And if this is a critical production system, don't you have some sort of system monitoring application - tivoli? nagios? - that could be used?
# 5  
Old 12-16-2014
Hi,

Below is the Linux version which we are using. We have Non production environment support, so no monitoring tools are available as it is newly formed team.

Code:
uname -r
2.6.18-308.11.1.el5xen

Thanks,
Anusha
# 6  
Old 12-16-2014
Anusha,

The reason I asked for the O/S is that Solaris-1x and RHEL-7.x have mechanisms to restart services. But your system is running RHEL-5.8.

You need to determine how quickly you need to respond to a dead queue manager. There is no such thing as instantly. For non-production, every ten to fifteen minutes would be reasonable.

As far as checking, why not just check for everything is not running:
Code:
HOST=$(uname -n)
FILE=$(mktemp)
trap "rm -f ${FILE}" EXIT
dspmq | grep -v Running > ${FILE}
if [[ -s "${FILE}" ]]; then
  mailx -s "${HOST}: queue manager is down" "${@}" < ${FILE}
fi

As far as re-alerting in an hour ... why? As RudiC stated, if you need to be renotified every hour that a queue manager is down, then you only need to check once an hour. Remember, there is no guarantee that the first notification will be noticed. I think a more robust (and simpler) method would be to check every 10 minutes and notify any time a queue manager is down.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A shell script to run a script which don't get terminated and send a pattern from the output by mail

Hi Guys, I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies

2. Shell Programming and Scripting

Shell script to be run every one hour

How can we run shell script every one hour. Anyone having code unit for this? (1 Reply)
Discussion started by: Pratiksha Mehra
1 Replies

3. Shell Programming and Scripting

To run a job for every one hour and ...

Hi, Someone please help me to run the script to maintain a Job: Which can be run for every one hour and should maintain the last two hours files only. It should delete the rest of the files in a dir. Please suggest me with the sample script. Thanks !! Reagrds, Rama (5 Replies)
Discussion started by: ramagore85
5 Replies

4. Shell Programming and Scripting

How to run script automatically every 12 hour once?

Hi ! all, I have once script to remove temporary cache and temporary xml files looks like this, as it is taking more space, I would like to run automatically every 12 hour once, and then I want to receive some log as acknowledgement #!/bin/sh echo "Removing logs and temp files (typically... (4 Replies)
Discussion started by: Akshay Hegde
4 Replies

5. Shell Programming and Scripting

E-mail based on crontab hour

I have a cron: 0 5,11,17,23 * * * /home/oracle/scripts/sysize.ksh This cron will trigger cat dbsz.txt | mail -s "$TODAY: PROD DB Size" $RECIPIENTS I don't want to get the e-mail notice 4 times a day. Can I have just one e-mail triggered at 11 AM? Please advise. Thank you (3 Replies)
Discussion started by: Daniel Gate
3 Replies

6. Shell Programming and Scripting

Script for checking files for last hour and send a mail

Hello, I need to write a script to check the files in one folder , if that folder doesn't have files generated from last 1 hr then we need to send mail to particular persons. So Can you please help me to write script to check the files and send email. Thank you.. (1 Reply)
Discussion started by: archana23
1 Replies

7. Shell Programming and Scripting

How to run the particular command continously for 30 mins in perl?

Hi, I have command that should run continuously for 30 mins but not every day not once in a week , not one in a month. whenever i call that particular program that command should run for 30 mins and stop. #Contents of test.pl `ls -l *.txt`; #some other lines of code to print ... (1 Reply)
Discussion started by: vanitham
1 Replies

8. Shell Programming and Scripting

Finding mail per hour

Hi, i have a logfile of a mail server it looks like this: d k 1004210238.380677500 1004210238.454490500 1004210238.679567500 3621 <VOLENDAM@Malawi.com> local.EDAM@Frankrijk.com 6053 81 I have got the following script to set the time in normal gmt time and to filter de failed messages, but i... (2 Replies)
Discussion started by: Prince2
2 Replies

9. Shell Programming and Scripting

Run a script on the hour but only for 30mins

Hi All, I want to run a script on the hour during a 24 - hour period; easy enough cron will take care of that..however I want the script to only run for only 30mins.. so with the script it knows its 30mins are up so exits. any ideas? Any help, greatly appericated. Thanking you all... (2 Replies)
Discussion started by: Zak
2 Replies

10. UNIX for Dummies Questions & Answers

Script should run continously

Hi I have a small req. I have a script called as abc.sh I want to execute this script continously for every 1 minute even if i exit from the server i.e., it should keeps on running for every one minute even if i logged off Can any one send me the sample code or procedure to work... (3 Replies)
Discussion started by: pssandeep
3 Replies
Login or Register to Ask a Question