Logic to send email alerts only 5 times a day


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Logic to send email alerts only 5 times a day
# 1  
Old 02-14-2011
Logic to send email alerts only 5 times a day

Hi,

I have written below disk space monitoring script to monitor disk space every minute. I have scheduled this script through cron. But now my problem is this script alerts the users continuously until the space is freed up. These emails are filling up the inbox exponentially until the space has been freed up. Please let me know how to stop sending the email alerts after 5 times and check for next day if the space is not freed up, then repeat the process.

Code:
. /home/.profile

# Get the list of Integration Service

infacmd.sh listservices -dn $INFA_DOMAIN -un Administrator -st IS | sed '$d' > $scripts_path/temp_ds.txt

while read line

   do

   ISDir=$(grep $line < $scripts_path/integration_services.txt | awk '{print$2}')

   echo "Integration Service path:"$ISDir


   disk_limit=$(grep $line < $scripts_path/integration_services.txt | awk '{print$3}')

   echo " "
   echo "Defined threshold limit for file system of data directory ${ISDir} is ${disk_limit}."
   echo " "

df -k ${ISDir}
        total_disk=`df -k ${ISDir}|tail -1|tr -s ' ' ' '|cut -f2 -d " "`;export total_disk
        available_disk=`df -k ${ISDir}|tail -1|tr -s ' ' ' '|cut -f3 -d " "`;export available_disk
        disk_percent_used=`df -k ${ISDir}|tail -1|tr -s ' ' ' '|cut -f4 -d " "`;export disk_percent_used
        used_disk=`expr ${total_disk} - ${available_disk}`
        mounted_file_system=`df -k ${ISDir}|tail -1|tr -s ' ' ' '|cut -f7 -d " "`;export mounted_file_system

        if [ ${used_disk} -ge ${disk_limit} ];
           then
                echo " "
                echo "WARNING:"
                echo "Available disk space of file system ${mounted_file_system} for Integration Service directory ${ISDir}"
                echo "is ${used_disk} Kbytes which is greater than the defined threshold limit of ${disk_limit} Kbytes."
                echo " "
                echo "Please increase size of file system ${mounted_file_system} for PowerCenter Integration Service Directory ${ISDir} before"
                echo "Informatica file system runs out disk space otherwise Informatica PowerCenter operations may be compromised."

        #Notification module
                echo "WARNING: ${ISDir} filesystem has exceeded their upper limit. Available disk space of file system ${mounted_file_system} for data directory ${ISDir} is ${av
ailable_disk} Kbytes which is greater than the defined threshold limit of ${disk_limit} Kbytes. Please increase size of file system ${mounted_file_system} for PowerCenter Integr
ation Service Directory ${ISDir} before Informatica file system runs out of disk space otherwise Informatica PowerCenter operations may be compromised."|mailx -s "Email notifica
tion of Integration Service directory exceeding defined threshold" ${alertlist}
        echo " "
        echo "Note:  Email notification of Integration Service direcroty exceeding defined threshold"
        echo "was sent to ${alertlist}"

        fi

    done < $scripts_path/temp_ds.txt

    rm $scripts_path/temp_ds.txt

Regards,
Sam
# 2  
Old 02-14-2011
Still just in theory

Is your alertlist a single person?
If so, after you email, do the following
append a file with some key info
date (as YYYYMMDD), alertlist

Then, before you email, you could do a
Code:
cat logfile | grep YYYYMMDD | grep alertlist | wc -l

and see if you have already sent five times
# 3  
Old 02-14-2011
Quote:
Originally Posted by joeyg
Is your alertlist a single person?
If so, after you email, do the following
append a file with some key info
date (as YYYYMMDD), alertlist

Then, before you email, you could do a
Code:
cat logfile | grep YYYYMMDD | grep alertlist | wc -l

and see if you have already sent five times
My alert list has multiple recipients. Please let me know how to do it.
# 4  
Old 02-14-2011
If alertlist has many names, then follow same idea, just break the line into individual names. Write each entry to the log file.
You will also need to break you email into individual emails in order to check for existence of five prior messages for the same day.

hard for me to say how to break apart your alertlist, since I do not see where you build that variable inside your script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop to execute 2 times and send an email alert

After the successful start of server, it should check the status again, if it is not running ,it should go through the loop for 2 times. Even after two times of execution if still the server is not running it should send an alert email. Please help (1 Reply)
Discussion started by: thomas9192
1 Replies

2. UNIX for Dummies Questions & Answers

Send email attachment using Operating System Script(UNIX) in Oracle Alerts

Good Day Kindly assist: I am creating an Alert that will notify supervisors of staff members who are due for probation report. I am using Operating System Script(Unix) as source.I have already developed the script. Now the challenge is if there are 3 employee records then the alert... (2 Replies)
Discussion started by: nosi27
2 Replies

3. UNIX for Dummies Questions & Answers

How to send alerts to the sysmon facility?

We are moving from using the syslog facility to sysmon. My question is what API's are used to write alerts to sysmon (2 Replies)
Discussion started by: thenrett
2 Replies

4. AIX

How to write a script to send these alerts?

Hello AIXians :) I want to complete this task using a script. The task is: We have a file called (alerts.log), this file is receiving all new alerts from ORACLE application all the day, I want to send email to a specific mail address when this file receives all alerts that starts with... (5 Replies)
Discussion started by: Mohannad
5 Replies

5. Solaris

ALOM Email Alerts

Hi I'm new to this forum and I was hoping you can help me with this strange activity. I have a Sol10 sun4u sparc SunFireV250 machine. Currently running ALOM 1.6.8 firmware. The following error was experienced on this machine: "Input power unavailable for PSU @ PS0" Reading the documention... (0 Replies)
Discussion started by: La-Paloma78
0 Replies

6. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

7. Shell Programming and Scripting

How to send email once a day at certain time in unix shell script

hi, i have to send an email once a day at ceratin time say 22. i have tried with date commad, but not working.:( HOUROFTHEDAY=`date +'%H'` if ; then mailx -s "Info" emailid@org.com < $ProcessStatisticsFile fi Please help me... (5 Replies)
Discussion started by: sreelu
5 Replies

8. Shell Programming and Scripting

script that reads a value and send an email on 89th day

hi all, Currently in my system a user's password expires after 90 days and the last passsword change time is stored in an attribute pwdchange date. i need a linux script that read this attribute and add 89 days and send an email that the user password is expiring the next day. i can store... (1 Reply)
Discussion started by: manankapoor
1 Replies

9. UNIX for Dummies Questions & Answers

Email Alerts

hi I am running so scripts that clean up empty folders on our servers once a week. I run from a cron. But what i would like to do is add a email notfication so i can be notified that it completed. The script is #Clean Empty Folders on Studio Share perl... (1 Reply)
Discussion started by: treds
1 Replies

10. IP Networking

Email Alerts

Dear Network Masters, I want to know who brought up the concept of Email Alerts Feature. are their any RFC's on Email Alerts???? Please let me know. Thanks in Adv, meti (1 Reply)
Discussion started by: ashokmeti
1 Replies
Login or Register to Ask a Question