Hello. I'd like to imply about the PRTG 13's possibilities of monitoring the applications' log-files. I suppose it can be done with the File Content sensor, right? However if the sensor finds what it searches for and goes to a warning state, it keeps this state 'til the log-file is re-written. Is there a way to search only the end of a log-file?
Monitoring log-files
Votes:
0
6 Replies
Votes:
0
Hello,
thank you very much for your KB-Post. I'm very much afraid the File Content Sensor is not able to "solve" this task. You could achieve this though with a self - written Custom Exe/Script Sensor.
Best regards.
Votes:
0
Darina,
I use the File Content Sensor with a custom script to perform what you are referring to. Example powershell below to retrieve the latest log file, parse out the last 25 lines to a file, point the File Content Sensor to that file to only see the end of the log file.
Configuration Guide:
- Open both elevated x86 and x64 Powershell, set-executionpolicy Unrestricted
- Add service account user to ACL for c:\scripts, permit read/write
- Configure task scheduler to run the script every 10 minutes, run as service account
- Configure the sensor to check this file and roll-up to the sensor ID ever 10 minutes
- Change select - Last from 25 to however many lines you want to parse at the end of the log file
$files = Get-ChildItem \\servername\logpath\logfile* | Sort-Object LastWriteTime -descending $fileName = $files[0].FullName Get-Content $fileName | select -Last 25 > c:\SearchStatusMonitor.log
Created on Sep 20, 2013 5:56:05 AM
Last change on Sep 20, 2013 8:00:50 AM by
Torsten Lindner [Paessler Support]
Votes:
0
Randolfini,
Thank you, I'll try to configure it the way you suggested. Just one question - what do you mean by "roll-up to the sensor ID ever 10 minutes"? I'm afraid I'm not quite getting this part, could you please explain it?
Votes:
0
Darina,
Sure, sorry I didn't explain #4 very well. I've found that if I use the built-in sensor for file content it has issues reading the file (cannot recall all the details, but it is a permissions problem). So instead I use the stand alone sensor, LogFileReader.exe, which should exist in C:\Program Files (x86)\PRTG Network Monitor\Sensor System\, or just Program Files if you are not running the x64 version.
Add a custom sensor, EXE/Script, find LogFileReader.exe in the list. In the parameters field I use -f=C:\Scripts\SearchStatusMonitor.log -s="system error code" -id=32563 -l
The parameters are
-f=file
-s=searchstring
-id=sensorID *This is where you put the sensorID of the sensor you created and what I meant by "roll-up to the sensor ID"
[u-username]
[-p=password|passwordhash]
[-r=RegEx]
[-l] Optional, returns the linenumber of the found string
[-t] Optional, returns the found textline as output message
Created on Sep 26, 2013 12:55:30 PM
Last change on Sep 26, 2013 1:05:53 PM by
Torsten Lindner [Paessler Support]
Votes:
0
Randolfini,
Got it! Thank you very much again for your suggestion and help.
Votes:
0
Something to add, the script is looking for a file that confirms to your name and then it looks for the most recent one. This is useful for log files that roll daily.
Add comment