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),
Pls check the attachment for the detailed error messages Exact situation: There was a problem and the server is reporting it every second and it was friday, my weekend. So after checking my mails on monday i., 2 days later, I received 60X60X60=216000 !! e-mails for the SAME message. I do not want same email these many times. If it is different messages, it is absolutely fine.
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?
This is an example only not the exact situation. You can consider "JS_callout as a keyword here in this example"
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?
Yes, my script runs every minute and checks the NEW lines in the database server errorlog for the errors (keywords) and send send an e-mail to my outlook account IF ANY.
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?
NO, I do not want emails for recurring messages within small duration I'm ok if it sends the same error message (if received) for every hour
Why are you counting sixteen keywords as errors but only sending e-mail for fourteen of those keywords?[/QUOTE] You can ignore the keywords part here. It is working fine and as per requirement
I guess your process has a faulty design from the beginning.
Running the log check every minute makes sense only if you react within the minute. Estimate your reaction time and reduce the job's frequency adequately.
Composing the grep ... command pipe will trigger one single mail if any of the keywords is found any no. of times in the NEW part of the logfile, which requires the new lines to be identified correctly. You may want to reconsider that.
Creating a sensible schedule and setup for the log check, you should receive, say, 48 mails for the weekend, unless you reduce the frequency even further for out-of-office hours.
I could not understand your statement "I guess your process has a faulty design from the beginning."
Running the log check every minute makes sense only if you react within the minute. Estimate your reaction time and reduce the job's frequency adequately.
This is meaningful and i will consider to change the frequency of the CRON job
Composing the grep ... command pipe will trigger one single mail if any of the keywords is found any no. of times in the NEW part of the logfile, which requires the new lines to be identified correctly. You may want to reconsider that.
I'm already aware of this.
Creating a sensible schedule and setup for the log check, you should receive, say, 48 mails for the weekend, unless you reduce the frequency even further for out-of-office hours.
You mean running the job for every hour? I will think on this.
Can you answer the following situation:
Imagine the CRON job is scheduled for every 10 minutes
The following are the new entries in the errorlog
JS: failed to receive jsagent response
Job Scheduler Task lost its Agent connection (Error 0)
Job Scheduler Task connected with Agent on port 4903
I will receive only 1 email for this. Agreed and accepeted.
Now, at next run(20 min later) I received the new and same error messages int he errorlog
JS: failed to receive jsagent response
Job Scheduler Task lost its Agent connection (Error 0)
Job Scheduler Task connected with Agent on port 4903
And again in the next run, same scenario and soon
Can you let me know how can we stop the script sending e-mails for the second run and thereafter (for same error messges scenario).
How about doing a sort | uniq -c on your new grepped results and the old extract (saved somewhere), and if the count is = 1, mail the error?
That would suppress identical lines; but a deviation of the slightest iota would issue a mail.
The notified file keeps track of error messages that have been detected. This file needs to be removed once errors have been cleared.
Remove the lastline file if you want the rescan the entire logfile.
You should also consider having a second cronjob that runs daily or weekly that removes the ${LOGSENT} file. This would ensure that you get notified at least once daily of a reoccurring problem.
- DL
---------- Post updated at 07:55 AM ---------- Previous update was at 07:41 AM ----------
I also missed the attached logfile, so please change:
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)