Monitoring log for FATAL in last 15mins only


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Monitoring log for FATAL in last 15mins only
# 1  
Old 05-16-2012
Monitoring log for FATAL in last 15mins only

Hi all,
I need to develop the following script. Could anyone please provide me some inputs.

1) Monitor the system log file (sys.log) for any lines in the parameter file that will contain all the different phrases of FATAL errors that the process has to scan for in the sys.log.

If any FATAL messages are found then an email notification has to be sent.

2) The process should look for errors only from the point of time when the last monitoring took place. For eg; if the first monitoring process ran at 8:00am CT, the next one that runs at 8:15 am should look for these errors from 8:01am time mark

This is how the sys.log looks like:
Code:
May 15 11:10:41 <hostname> xy_updserv[29245]: +++INFO+++ initialization complete
May 15 11:10:48 <hostname> xy_qryserv[29243]: +++INFO+++ initialization complete
May 15 11:10:49 <hostname> xy_qryserv[12345]: RPC: using socket receive timeout of 0 seconds
May 15 11:10:49 <hostname> xy_updserv[13445]: RPC: using socket receive timeout of 0 seconds
May 15 11:12:32 <hostname> xy_qryserv[12343]: +++ERROR+++ Warning: could not load '/abc/az/xyz/file.fe' 
May 15 11:27:21 <hostname> xy_qryserv[10905]: +++ERROR+++ Info: FATAL - data missing
May 15 11:42:19 <hostname> xy_qryserv[731]: +++FATAL+++ initialization failed. Aborting...

This is how the param file looks like:
Code:
+++ERROR+++ Info: FATAL - data missing
+++FATAL+++ initialization failed. Aborting...

Thanks all!!

Moderator's Comments:
Mod Comment Code tags for code, please.

Last edited by Corona688; 05-16-2012 at 02:59 PM..
# 2  
Old 05-16-2012
What's your system? What's your shell?
# 3  
Old 05-16-2012
If you have GNU date:

Code:
$ cat last.awk

BEGIN {
        split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", M);
        for(X in M)     MON[M[X]]=X;
}

{       D=sprintf("%02d %02d %s", MON[$1], $2, $3);     }

D >= LAST

$ # Filter out all relevant errors
$ grep -F -f param data |
        # Print only those that meet the date criteria
        awk -v LAST="$(date -d "-15 minutes" +"%m %d %H:%M:%S")" -f last.awk

...
...
...

$

# 4  
Old 05-16-2012
Im working on Linux 2.6.18 and bash.
# 5  
Old 05-16-2012
Excellent, I think that should work for you then.
# 6  
Old 05-16-2012
Ill try this..
Thanks for your help!!
# 7  
Old 05-16-2012
How to capture the logs in last 4 hours from the consoldated log files

Hi All,

Could you please help me to write bash script to grep the logs captured in last 4 hours from the consolidated log file (Log file will be manually truncated for every 2 months).

Below is sample log:
Code:
[ebizz@DL-RP-INDIA sampath]$ sed -n "/ $(date +\%R -d "-240 min")/,$"p ebiz.log | head
24 Mar 2012 10:53:58 WARN  [ALLCUSTOMERS-ResponseProcess91_CLK] ResponseProcess - HFM2.CLK.BIDNF:HFM2,139722096,655060,2012-03-24 10:23:51,H,83.79.171.236,Firefox
24 Mar 2012 10:53:58 WARN  [ALLCUSTOMERS-ResponseProcess91_OPN] ResponseProcess - HFM2.OPN.BIDNF:HFM2,141416951,H,2012-03-24 10:23:01,96.52.244.133,Firefox
24 Mar 2012 10:53:58 WARN  [ALLCUSTOMERS-ResponseProcess90_OPN] ResponseProcess - HFMU.OPN.BIDNF:HFMU,62553304,H,2012-03-24 10:23:52,64.131.219.114,Others

By using the above command i am getting all the log details from March 24 but i am expecting to get the last 4 hours logs only.

Please helpful me and thanks in advance...Smilie

Last edited by Franklin52; 05-17-2012 at 02:07 PM.. Reason: Code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

PHP Fatal Errors During SSL Cert Management - PHP Fatal error: xc_fcntl_mutex failed

Today, I noticed some errors in our SSL cert renewal log files, mostly related to domains where the IP address had changed. Concerned about this, rebuilt out SSL cert, which normally goes well without a hiccup. However, for today, for some reason which I cannot explain, there was a PHP error... (0 Replies)
Discussion started by: Neo
0 Replies

2. UNIX for Beginners Questions & Answers

Monitoring script for Log file

Hi, Iam new to unix , plz help me to write below script. I need to write a script for Monitoring log file when any error occurs it has to send a mail to specified users and it should be always pick latest error not the existing one and the script should be able to send mail all errors (more... (1 Reply)
Discussion started by: vij05
1 Replies

3. Shell Programming and Scripting

How to capture last 15mins data logged from server.log file?

Below is Script to scan the errorlist file (errorlist file includes a list of errors) with sererv.log file (sererv.log file should contain data of recent 15mins ) but my requirement is I should get the recent logs i.e. cmd to capture only recent 15mins data logged from sererv.log file then scan... (3 Replies)
Discussion started by: manohar2013
3 Replies

4. Shell Programming and Scripting

Tomcat Monitoring log file

Hi, I ned to monitor the tomcat log file called "catalina.out" for "OutOfMemory" ,"java.sql.SQLException" and "Error" error. the script should monitor this file (catalina.out) and send us the mail as soon as it finds the string "Out of memory" or "java.sql.SQLException" or "Error" in the... (2 Replies)
Discussion started by: mnmonu
2 Replies

5. Shell Programming and Scripting

help with email to be triggered based on fatal error detection from batch run log file neded

Hi, I require need help in two aspects actually: 1) Fatal error that gets generated as %F% from a log file say ABClog.dat to trigger a mail. At present I manually grep the log file as <grep %F% ABClog.dat| cut-d "%" -f1>. The idea is to use this same logic to grep the log file which is... (1 Reply)
Discussion started by: zico1986
1 Replies

6. Shell Programming and Scripting

log monitoring

Hi All; I have a log file(dynamic) which i need to monitor; the format of the log file is as follows #Session ID STATUS The status can be one of the three /starting ;/loading ;/success Example #Session ID STATUS ABC /started.html XYZ /started.html ABC /loading.html ABC... (2 Replies)
Discussion started by: maverick_here
2 Replies

7. Shell Programming and Scripting

Monitoring log file

Hi, I ned to monitor the tomcat log file called "catalina.out" for "Out of memory" error. the script should monitor this file and send us the mail as soon as it finds the string "Out of memory" in the file. can ypu suggest me which is the best way to do this? (4 Replies)
Discussion started by: shivanete
4 Replies

8. Windows & DOS: Issues & Discussions

Log monitoring in windows

Hi, I'd like to know if there is a way to monitor a log file conitnuously for one or more strings and if found, send an alarm. It should also take care not to inlcude the old log file entries. Thanks. (2 Replies)
Discussion started by: er_ashu
2 Replies

9. Shell Programming and Scripting

Log Monitoring through Perl

Hi, I am new to perl. I want to write a perl script to monitor logs. Where i want to monitor exceptions logged or any kind of error strings. I have a dir(On Solaris) with multiple log file which keeps rolling to .gz file after some time in that same dir. These logs files size keeps on... (0 Replies)
Discussion started by: solitare123
0 Replies

10. UNIX for Dummies Questions & Answers

log monitoring

Hi there, I have an application runnig on HP_UX which logs critical mesages to a log file. What I would like to do is tail the log file and report on new messages. Easy....I here you say. The log file is continuing to be written to and the check scritp will be executed from cron. I was... (2 Replies)
Discussion started by: nhatch
2 Replies
Login or Register to Ask a Question