How can I search for multiple log entries in one log file since the File Content Sensor can only search for one string?


Article Comments

This can be done with a custom script and the EXE/Script Advanced sensor. Following script needs to be saved as .ps1 file and stored in \Custom Sensors\EXEXML

param([string]$Path, [string[]]$Strings)

Write-Output "<prtg>"

foreach ($String in $Strings) {

$NumberString = Select-String -Path $Path -Pattern $String -AllMatches

$ValueString = $NumberString.Matches.Count

Write-Output "<result>
           <channel>$String</channel>
           <value>$valueString</value>
           </result>"
}

Write-Output "</prtg>"


Afterwards you can add the sensor and add following in field Parameters:

-Path "C:\YourLocation\Logfile.txt" -Strings YourString1,YourString2,YourString3

Important: Please note that officially we do not support customization of any kind. If it's not working as expected, or if it stops working with newer PRTG versions, we won't be able to assist you further. Please also refer to the following article which explains why we can't officially offer any customization help for PRTG: https://helpdesk.paessler.com/en/support/solutions/articles/76000065319


Mar, 2022 - Permalink