Log Parser (Perl)
Use this SAM application monitor template to check a specified log file and determine the total number of lines that match your search criteria.
Prerequisites
Perl is installed on target servers.
Credentials
Root access is granted on target servers.
Component Arguments and Syntax
These three arguments are used in the following order: perl ${SCRIPT} "LogFilePath" "RegularExpression" "Position"
Log file path
: The path of the log file on the target server. The path can contain spaces, unlike the PowerShell version of this template for Windows that does not support spaces.Regular Expression
: Used to find a desired string in the log file in Regular Expression (RegEx) searches. Searches are case sensitive and can contain spaces.-
Position
: This value determines the position from the last string of the log file in the Found String in # Position monitor. For other monitors, this takes part in generating temp files.For the Total Number of Strings Found and Number of Newly Found Strings monitors: If you monitor the same file but different search strings, use random values in the Position argument to generate different temp files.
The following example of the Number of Newly Found Strings component monitor searches the /etc/inittab"
log for any strings that include init
that were added since the last time the script ran .
perl ${SCRIPT} "/etc/inittab" "init"
Component monitors
Total Number of Strings Found
This monitor shows the total number of strings that match the search criteria in the entire log file. It also returns strings that match search criteria, as shown in the Message field and separated by ";
" characters.
Here is a Command Line example: perl ${SCRIPT} "/etc/inittab" "init" "0"
Number of Newly Found Strings
This monitor shows the number of newly found strings after the last script execution. It also returns strings that match search criteria, as shown in the Message field and separated by ";
" characters.
Here is a Command Line example: perl ${SCRIPT} "/etc/inittab" "init" "0"
Found String in # Position
The line number of the last match found in the file.
In this Command Line example, the Position argument is “1”: perl ${SCRIPT} "/etc/inittab" "init" "1"