I want my script to NOT to send an e-mail if it finds the same keyword more than twice.
My script triggers and e-mail if keywords supplied to it were found.
Problem is if it find the same keyword continously (due to continous server errors), it triggers mails and fillup my mail box with same message (which is not required)
I want my script to NOT to send an e-mail if it finds the same keyword more than twice.
Following is my script
Any help in this regards is highly appreciated
Best Regards,
Rajesh
Last edited by Don Cragun; 11-26-2014 at 09:44 AM..
Reason: Add CODE tags.
Just to clarify the purpose of the script - this script is run periodically (via cron?), and when it runs, it looks for keywords in the "new" part of the logfile (what was appended since the last time you ran the file), and finding them, is supposed to send you one email?
---------- Post updated at 08:54 AM ---------- Previous update was at 08:52 AM ----------
And by "finds the keyword twice", do you mean you've gotten more than two emails for the same keyword? Or for any of the keywords? What would clear the condition - not finding the error when the script is run?
Yes, the script is run via CRON (every minute)
Yes, it looks for keyword from the "new" part of log file
Yes, I received more than 500 same e-mail, when the same error occured more than 500 times
No of e-mails is proportional to no of (same)error messages, whihc i dont want. (I want only one e-mail if the error is recurring)
Thanks
Rajesh
---------- Post updated at 09:41 AM ---------- Previous update was at 09:23 AM ----------
Consider the following situation
I receive an 4 e-mails if the same error is repeating.
Now imagine the situation with 500 errors (same and continous)
What I'm looking at is, if the script detects the same error as detected earlier (due to continous errors generated by the server), it should not send me an e-mail for the second time. Just one e-mail is enough.
This is just to stop inbox full situation
Last edited by zaxxon; 11-26-2014 at 11:04 AM..
Reason: code tags
Yes, the script is run via CRON (every minute)
Yes, it looks for keyword from the "new" part of log file
Yes, I received more than 500 same e-mail, when the same error occured more than 500 times
No of e-mails is proportional to no of (same)error messages, whihc i dont want. (I want only one e-mail if the error is recurring)
Thanks
Rajesh
---------- Post updated at 09:41 AM ---------- Previous update was at 09:23 AM ----------
Consider the following situation
I receive an 4 e-mails if the same error is repeating.
Now imagine the situation with 500 errors (same and continous)
What I'm looking at is, if the script detects the same error as detected earlier (due to continous errors generated by the server), it should not send me an e-mail for the second time. Just one e-mail is enough.
This is just to stop inbox full situation
I guess I still don't understand your requirements. You show four lines above and say you only want one message for those four lines (not four messages), but none of the keywords in either of the egrep commands in your script are in those four lines. So, why should any message be sent?
Let me see if I understand what you're trying to do. You're running your log processor every minute, and you're only looking at new messages in the log file each minute. So, are you saying you want a mail message each minute of the day in which that error is reported? With the sixteen keywords in your 1st egrep (there are only fourteen in the 2nd egrep) do I correctly understand that you're OK getting 16 messages each minute for each minute of the day (for a maximum of 23,040 messages in your mailbox each day) as long as no two messages sent by any invocation of your log checker contain the same keyword? Are the lines that you show above supposed to generate mail messages or not? (As I said before, none of your keywords are present in those lines.)
Why are you counting sixteen keywords as errors but only sending e-mail for fourteen of those keywords?
I am having trouble getting mail to work on a red hat server. At first I was getting this message.
Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused
Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
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)
I want to search a file if it contains special strings and if yes, the records found should be mailed.
I can either do it with a temporary file:
/usr/bin/grep somestring somefile > /tmp/tempfile && /usr/bin/mail -s "Found something" email@mycomp.com < /tmp/tempfile... or by running the grep... (10 Replies)
Dear Masters,
I am using Solaris 10 and bash shell. I make a script for checking if a file is exists on the specified folder or not from 5th day of the month until the end of the month. If the file doesn't exist, the script will send email to me. The script ran perfectly when I execute it on... (6 Replies)
I have written small piece of code to send mail through perl script.Below is the code.I have executed it as #
perl perlmail.pl and the code got executed with no errors.
Still have not received any mail.
Also I have installed Mail::send module from CPAN directly but no luck.
Could any mail... (2 Replies)
Hi Experts..
i have created a table with the fields,
empid name mailid
1 raja raja@xy.com
and entered the values of all persons who are in that file...
i have a .csv file
date shift1 shift2
6/6/2011 ram raja
Now i want a script that could fetch the data in (input file .csv file) and... (3 Replies)
Hi,
I have written one script for sending mails with attachment.
currently its working for only one recipient.
I want to send mails to n number of users by taking user input i.e number of users.
Output of current script:
Enter how many files : 1
Enter First Name : kiran
E-Mail... (2 Replies)
i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail.
actually i am trying to automate the high... (2 Replies)
Hi,
I need to write one unix script gor sending a mail notification.
I have to pass the followinf as arguments,from ,to,subject,messege body
Can i use mailx....Please provide the code
Thanks in advance. (1 Reply)