What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

logfile content check sensor

Votes:

0

I would like to monitor the content a a log file generated by an application. Unfortunately, the name of the logfile is not static. Would be nice to have some regex or placeholder functionality in the sensor config menu! Additionally, it would be nice to be able to configure how PRTG should react in case if the logfile doesn't exist (ie the application has not been started) Do you see a practical workaround? Best regards, Tilman

config filename logfile-sensor

Created on May 30, 2011 1:12:05 PM



6 Replies

Accepted Answer

Votes:

0

Use a batch file

If your log file is the result of a backup job, there is most likely an option to run a batch file after the completion of the job. In this batch file, copy the log file to a file with a fixed name.

copy "your_log_file" c:\temp\checkthis.txt /Y

and have the sensor check the "c:\temp\checkthis.txt" file.

This way the file will always exist and the sensor will not return an error.

More advanced solution

There is a small catch in the solution above. If the file contains text that should trigger the sensor and the sensor is already triggered by the previous version of the "c:\temp\checkthis.txt" file, notifications will not be send again.

To overcome this, we first need to make sure that the "c:\temp\checkthis.txt" file contains no text that triggers the sensor and force the sensor into an OK state by running the sensor.

The new batch file will now look something like:

rem ** create a file that will not trigger the sensor **
echo The sensor will not trigger on this text > "c:\temp\checkthis.txt"
rem ** force the sensor to run using cUrl **
curl yourPRTGserver/api/scannow.htm?id=objectid&login=user&password=password 
rem ** wait for 5 seconds **
ping 1.1.1.1 -n 1 -w 5000 > NUL
rem ** copy the log file **
copy "your_log_file" c:\temp\checkthis.txt /Y

Replace objectid with the ID of your sensor.

Created on May 31, 2011 7:54:54 AM



Votes:

0

Hi, Thanks for your help! The problem is that it should be a "realtime" monitoring of the logfile. I'm afraid I've to dig into some vb or powershell code... Best regards, Tilman

Created on May 31, 2011 11:13:23 AM



Votes:

0

How is the name of your log file build up?

Created on May 31, 2011 1:04:46 PM



Votes:

0

the application writes an rtf with a name such as 20110511_1520.rtf yes: it's really a rtf :-(

-> what I'll try to do next. write some vb or powershell code which looks for the oldest file (according to the filename). parse it, strip the rtf tags, return the line with timestamp if keywords match. Better solution are allways welcome!

Created on May 31, 2011 1:30:16 PM



Votes:

0

hi, has there been a solution to this yet? I too have an application that starts a new log every night with a date in the filename. How can I get the content sensor to pick this file up every night?

Created on Oct 5, 2012 2:15:29 AM



Votes:

0

Hello,

Same type of need here. Web server is writing daily logs with name format logfile-trace-YYYY-MM-DD with not extension.

Need to grep out "Error FILE_OPEN_FAILED" and report on the rate of occurence.

Created on Feb 1, 2013 4:23:50 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.