473,749 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3071

-----Original Message-----
From: py************* *************** ****@python.org [mailto:python-
li************* ************@py thon.org] On Behalf Of m
Sent: Wednesday, August 06, 2008 1:25 PM
To: py*********@pyt hon.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
2703
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 T2, T3... try to enter the critical section and are blocked. What is the order that the threads get to enter the critical section?
14
5357
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 reaches another line of specified text. I know I can use the FileSystemWatcher class to see when the log file is changed, I just can't figure out how to retrieve what text was appended to the log file since the previous change. This log file is...
15
2708
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
2145
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. Why? I would appreciate it if someone could help me understand the ramifications of picking an object in this command. Thank you so much for your help. Clark
10
1806
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 bottom of almost every form. I haven't figured out yet if there's a pattern to it. I compared two forms -- one that looks okay and one that gets cropped, and aside from the size and the accept button and the cancel button, their properties are...
1
1774
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 ask where it seems I'm not beings specific or using the wrong wording. I am looking into a project for the company I work for. Essentially it involves setting up a real time monitor / signal injector in between a CPU board and a system...
11
3021
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 pass through in 1 hour send an email. So was thinking to use the shell command to grab the time when a file comes in and write to a txtfile. Now when the files keep coming it will overwrite the old time. Now if no new files are coming in an hour...
3
9610
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 difference between two source documents and output node-sets which are "different" (changed or new) to new XML files using xsl:result-document To describe the problem I have provided some example data below along with my a portion of my current...
0
1282
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 directly but haven't found any. Now I'm stuck to programming one. And I think it's easier to monitor it's files instead of monitoring directly each VM. Any help to a freeware program or a start is appreciated. I only have basic knowledge in VB using...
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8256
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.