Solved

Challange for Experts (Monitoring Log files)

Posted on 2006-06-19
10
281 Views
Last Modified: 2010-05-18
Dear VB Experts,

I need to build new applicatio using VB 6.0 to monitor a log file in a server, with frequintly repeated check every period og time, the program has to detect if there is any new jobs recorded in the log file or any updates on an already existing job in this log.
Now if there is new job, a new record must be inserted in a table in SQLserver DB with incompleted status, and recheck again for new and updates. if there is new jobs then insert again else check for the aleardy inserted jobs and not completed if there is any updates or modifications to update the status.
So, My procedure is a monitoring for a log file in a fax server, each fax job has more than one record one when just entered the accepted and the ready to be sent finally its successfully sent or not. so i need to check, insert if new or update if existing and check again.

Please advice ASAP

Thnx in advance
0
Comment
Question by:obmtech
10 Comments
 
LVL 14

Expert Comment

by:dlwyatt82
Comment Utility
There's not really enough information here to help you, as this project depends entirely on the structure of the log file you want to monitor (and to a lesser extent, on the database you want to push information to).
0
 
LVL 9

Expert Comment

by:justchat_1
Comment Utility
3 ways to detect changes:

1. Check the last modified date of the file
2. record the file size
3. take an md5 hash of the file
0
 

Author Comment

by:obmtech
Comment Utility
Here is one succesfull job from my log file:



|100|2006/05/29 08:42:00|Received job from user "USER_NAME" (Job assigned ID 275018).|FAX|WEBSERVER|3|28553||fpFax.cpp|708|2524|2852|
|100|2006/05/29 08:42:00|Job 275018 placed in fax queue for processing. |FAX|WEBSERVER|0|0||fpFax.cpp|710|2524|2852|
|100|2006/05/29 08:42:33|Prefetch thread processing requests|FAX|WEBSERVER|0|0||FetchThread.cpp|51|2524|3072|
|100|2006/05/29 08:42:33|Fetching data objects for job 275018|FAX|WEBSERVER|0|0||FetchThread.cpp|145|2524|3072|
|100|2006/05/29 08:42:33|Prefetch Normal Document success for job 275018|FAX|WEBSERVER|0|0||FetchThread.cpp|162|2524|3072|
|100|2006/05/29 08:42:33|Data found and ready to be exported for job 275018|FAX|WEBSERVER|0|0||FetchThread.cpp|212|2524|3072|
|100|2006/05/29 08:43:26|OCR Page Licenses as of 5/29/2006 8:43:26 AM: 24201|OCR|WEBSERVER|3|0||OCRDongleThread.cpp|104|2524|3052|
|100|2006/05/29 08:43:30|Found a faxable job|FAX|WEBSERVER|0|0||FaxThread.cpp|215|2524|3068|
|100|2006/05/29 08:43:30|Fax thread processing requests|FAX|WEBSERVER|0|0||FaxThread.cpp|71|2524|3068|
|100|2006/05/29 08:43:30|Fax job 275018 found and ready to be fax. Retries remaining 2.|FAX|WEBSERVER|3|28556||FaxThread.cpp|130|2524|3068|
|100|2006/05/29 08:43:30|Job 275018 being posted to gamma queue for phone number "FAX_Number".|FAX|WEBSERVER|0|0||FaxThread.cpp|132|3068|
|100|2006/05/29 08:43:30|Job submitted to fax H/W|FAX|WEBSERVER|0|0||FaxThread.cpp|143|2524|3068|
|100|2006/05/29 09:08:31|Fax job 275018 successfully sent to CEO office. Fax Server: A|FAX|WEBSERVER|3|28503|USER_NAME|FaxBaseThread.cpp|66|2524|3084|
|100|2006/05/29 09:08:31|Fax job 275018 successfully sent to all users. Fax Server: A|FAX|WEBSERVER|3|28504|USER_NAME|FaxBaseThread.cpp|66|2524|3084|

***
WEBSERVER is the server name

I hope it will help
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 10

Assisted Solution

by:cool12399
cool12399 earned 250 total points
Comment Utility
Ok.

(a) Assuming that log file is a text file (i.e., "log.txt").
(b) I'm assuming you have the necessary read/write permissions/etc to your log file, etc, etc, and
that is not a huge log file (otherwise you'd simply use the 'seek' command in VB to go to the end of
the file and read the last line. A little extra coding, not a big deal).

Basically:

1. Create a VB app.
2. Add a 'timer' control.
3. Set your interval for how 'often' you want to check the log (i.e. every second? every minute? every 5 minutes?).
The 'interval' is in milliseconds, so 1 second = 1000.
4. In your timer code, simply do your read/write code to determine whether a new job has been added. Assuming
you are having this code running on your system, and staying open, one very easy way is simply to:
i) read through the entire text file (i.e., while not eof(1) ... read file ... wend), and stick the last line in
a global variable, say called 'lastLineRead'. Then, when you read the file this time, see if the last line read
is equal to the one you set in your global variable. If it is, then you don't need to do anything. Otherwise, you
do whatever it is you wanted to do with the new information.

And voila! You now know how to monitor your log files through vb6 code.
0
 
LVL 10

Expert Comment

by:cool12399
Comment Utility
oh, and yes, re: the SQL etc, of course, you would add the necessary SQL code (i.e., insert/update/etc whatever).
0
 
LVL 9

Accepted Solution

by:
justchat_1 earned 250 total points
Comment Utility
Even simpler and less resource intensive...

use LOF(filename) to store the size of the file

or

GetAttr(PathName As String) to get the last modified date

...personally the first one is the easiest
0
 
LVL 9

Expert Comment

by:justchat_1
Comment Utility
Correct answer given by me and cool12399, awaiting points...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now