Solved

Challange for Experts (Monitoring Log files)

Posted on 2006-06-19
10
283 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 58
VB6 - Compare and highlight cell not the same 3 49
Child Form in front 4 46
MsgBox 4 59
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 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

18 Experts available now in Live!

Get 1:1 Help Now