Monitor and compare two log files in real time

Shawn Milochik Shawn at Milochik.com
Wed Aug 6 14:17:45 EDT 2008


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



More information about the Python-list mailing list