Hello Friends,

I have a small challenge, i need to motify a shell script designed to monitor an oracle database. It should notify the DBA when the listener & database is down and also notify when there is any error in the alert log.

Note: The sendmail feature should not keep sending mail as long as the database is down but should check if the instance is down, it should fire a mail and every five minute it should fire a mail.

What i currently have keeps firing an email as long as the listener or database is down. So for any database downtime i get over 30000 mails.

Kindly help review the code. I have included the current shell i am using as an attachment.

Regards,
Whales.

Well, you're not waiting for 5 minutes before doing each check so naturally you'll have so many mails.. just sleep for 300 seconds between each check ONCE you detect that DB is down. If DB is up sleep for lesser time if you like frequent checks.
Other way of course is that you do the check at a constant frequency but sendmail only if time elapsed since last mail was sent is more than 300 seconds. For how to find time diff check this thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.