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
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 18.104.22.168 -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.
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
How is the name of your log file build up?
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!
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?
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.