Solved

Challange for Experts (Monitoring Log files)

Posted on 2006-06-19
10
286 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 14

Expert Comment

by:dlwyatt82
ID: 16936177
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
ID: 16937548
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
ID: 16940726
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Assisted Solution

by:cool12399
cool12399 earned 250 total points
ID: 16944797
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
ID: 16944805
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
ID: 16945410
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
ID: 17293840
Correct answer given by me and cool12399, awaiting points...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month7 days, 5 hours left to enroll

623 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