473,385 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Monitor and compare two log files in real time

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?
Aug 6 '08 #1
2 3058

-----Original Message-----
From: py********************************@python.org [mailto:python-
li*************************@python.org] On Behalf Of m
Sent: Wednesday, August 06, 2008 1:25 PM
To: py*********@python.org
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
Aug 6 '08 #2
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
Aug 6 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: vooose | last post by:
Suppose execution of a particular thread T1 hits Monitor.Enter(obj); //critical section and blocks at the first line. (ie someone else is in the critical section) Now suppose more threads...
14
by: MarcJ | last post by:
Hello, What I'm trying to do is monitor a log file for a certain line of text to be written to it. Once that text is written, I want to parse from that instance of the watched text until it...
15
by: Jim Hubbard | last post by:
Is it possible to emulate a monitor (create a virtual monitor) using vb.net? Any code snippets or pointers to helpful articles would be very much appreciated.
6
by: Clark Sann | last post by:
Can someone help me understand what object should be used as the lock object? I've seen some programs that use Monitor.Enter(Me). Then, in those same programs, they sometimes use another object. ...
10
by: RobinS | last post by:
Hello to all, and happy new year! I have this application that someone wrote that I'm sort of checking out. The forms look fine in design mode, but when I run the application, it crops off the...
1
by: frikk | last post by:
Hey Everyone! I've got a question regarding the capabilities of python in a real time environment. I'll start by saying I'm a little bit flaky when it comes to terminology, so please correct me or...
11
by: jonathan184 | last post by:
Hi I am trying to do a script to monitor a dir where files pass through approx every 5 mins but sometimes files may not come in for hours So the purpose of the script is to monitor by if no files...
3
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the...
0
by: lordfallout | last post by:
Is this possible? What I need is, to monitor the files of a virtual machine in real-time to check which VM is slowing down the system. I've researched for a program that can monitor the VM's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.