Fishing out error message within a log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fishing out error message within a log file
# 1  
Old 06-30-2006
Fishing out error message within a log file

Hi all,

i have a log file that captures success or failure messges when i run a daily job.
here is a sample of my log.

20060312 start
successful
successful
failure
failure
20060312 end

i need to write a subroutine that opens up the log daily after my job completes to examine the log and if there are failures alert me.
Code:
##########
script that perform the job. print out current time,records success or failure. when job ends, 
print out time when job started. 
###########
a small routine to open up the log, 
count number of times 'failure' appears demarked by the start and
end text and if count >1 email myself with the lines of failure.

how can i do it in perl? i am thinking along the line of storing the start and end line in two variables, open up the log, filter out the chunk of lines within the 2 variables and do a count. Any suggestions?
# 2  
Old 06-30-2006
What means the number 20060312 before start/end?
# 3  
Old 07-01-2006
The script below reverses logfile then searches text between end and start:

Code:
#!/usr/bin/perl -w

open (INPUT, "< logfile");
for (reverse <INPUT>) {
    if (/end/ .. /start/) {
        last if /start/;

        if (/failure/) {
##################################
# failure detected: do hear what you want, e.g
            print 'FAILURE';
#################################
            last;
        }
    }
}

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Colorful message is displayed in the terminal but not in the log file

Is there any way to print the colorful message in the terminal (which is the output of a simulation) to the log file with the same color. The colorful message at the terminal is obtained by the following codes: /////////////codes start here/////////////////////////////////////// ... (5 Replies)
Discussion started by: babunp114525
5 Replies

2. Shell Programming and Scripting

Searching Error Message from a log life between timestamp of every 10 minutes

HI Everyone, My task is to search error messages last 10 minutes everytime from a log file. My script, date1=`date -d '10 minutes ago' "+%H:%M:%S"` date2=`date "+%H:%M:%S"` awk -v d1="${date1}" -v d2="${date2}" '$0~d1{p=1} $0~d2{p=0} p' filename No error getting in... (3 Replies)
Discussion started by: ctscbe
3 Replies

3. UNIX for Dummies Questions & Answers

Cp problems, file exists but error message

Basically, I want to copy all files (F03*) in this directory and merge/paste them into a new file (called SMER_2.03.12.SPU), yet the error message is "no such file or directory." I listed what is in my working directory, and the files do exist, so I'm not sure what's going on. The code's at the... (8 Replies)
Discussion started by: ucsdee
8 Replies

4. Shell Programming and Scripting

Extract XML message from a log file using awk

Dear all I have a log file and the content like this file name: temp.log <?xml version="1.0" encoding="cp850"?> <!DOCTYPE aaabbb SYSTEM '/dtdpath'> <aaabbb> <tranDtl> <msgId>000001</msgId> </tranDtl> ..... </aaabbb> ... ... (1 Reply)
Discussion started by: on9west
1 Replies

5. Shell Programming and Scripting

Capture all error message in Log file and send the Log file by email

Hi I have a requirement to write a script to capture all errors in a Logfile and send the file in email. If there is any error occurred the subject of email will be ERROR , If there are no error occurred the subject of email will be SUCCESS. So I created a Log file and put the Appropriate... (2 Replies)
Discussion started by: dgmm
2 Replies

6. Shell Programming and Scripting

Help w/ script to read file and parse log message

Hi, I am working on the script to parsing the specific message like "aaaa" in multiple log files like N1-***,N2-***,N3-***... The script is to find the list of lof files which contains the message "aaaa" and export the list into excel filE. Can anyone give help? Thanks (2 Replies)
Discussion started by: shyork2001
2 Replies

7. UNIX for Dummies Questions & Answers

error message when use fork with open file

I get this message when I write myshell.c program "VM pagefault:SIGSEGV bad add 0x0 err 0x4 nopage read myshell PM: ciredump signal 11 for 1725 /myshell memory fault (core dumped)" /* RCS information: $Id: myshell.c,v 1.2 2006/04/05 22:46:33 elm Exp $ */ #include <stdio.h> #include <unistd.h>... (1 Reply)
Discussion started by: rosecomp
1 Replies

8. Shell Programming and Scripting

Send-file /var/log/message

Hello All i need Shell Script to send /var/log/message or another if he have or grep this file to have some info like PID or value (e.g like NFS mount - stop ) to some body in my System Thanks for Advanced (2 Replies)
Discussion started by: Hosam
2 Replies

9. UNIX for Advanced & Expert Users

Append error message to the log

In my unix system , I chceck that there are error message append to the /var/adm/syslog . But I also found that part of these message will pop to my login session ( I use telent to login to server ) , I also check the /var/mail/my_loginid is empty , could suggest how can I forbid the message pop to... (1 Reply)
Discussion started by: ust
1 Replies
Login or Register to Ask a Question