Monitor and compare two log files in real time

M

m

I have a script I would like to write but I am not sure of where to
start / approach. Perhaps someone could help direct me in the right
direction. Any advice is appreciated.

I would like to write a python script that monitors two log files.
If a certain string, lets say string1 shows up in logfile-A, I want to
check if that same string shows up in log file-B within 8 minutes. If
it does not show up within 8 minutes, send an email ( using sendmail
or postfix).

Do you have any suggestions?
 
R

Reedick, Andrew

-----Original Message-----
From: [email protected] [mailto:python-
[email protected]] On Behalf Of m
Sent: Wednesday, August 06, 2008 1:25 PM
To: (e-mail address removed)
Subject: Monitor and compare two log files in real time

I have a script I would like to write but I am not sure of where to
start / approach. Perhaps someone could help direct me in the right
direction. Any advice is appreciated.

I would like to write a python script that monitors two log files.
If a certain string, lets say string1 shows up in logfile-A, I want to
check if that same string shows up in log file-B within 8 minutes. If
it does not show up within 8 minutes, send an email ( using sendmail
or postfix).

Do you have any suggestions?
--

Google on "python tail" to get a python implementation of the unix tail
command. The rest should be easy.

http://code.activestate.com/recipes/157035/



*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622
 
S

Shawn Milochik

Can you be more specific? That will also help you write your
requirements, which will lead to your pseudo code and then your code.

Do you want to search for a a pre-defined string (or set of strings),
or just look for anything matching a pattern to appear in the first
file? Related question: Can that string appear anywhere in the second
file, or does it have to appear in a certain pattern (at the beginning
of a line, followed by a colon or the word "error" or something?

Do the log entries have timestamps, or will you be capturing the time
your script found the string in file 1? What will you do if the script
must be restarted and "forgets" what it found in the past eight
minutes?

If you're feeling ambitious, write some code. Figure out how to:

1. Read a file.

2. Locate the value(s) you are looking for and retain them somehow.

Once you can do those two things, you can easily read the second file
and seek the values you already found. A few lines to handle the
eight-minute rule, and you're almost done.

Post back when you have some code written.

ShawnMilo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top