References > Template Reference > Log Parser > Log Parser (Perl)

Log Parser (Perl)

The Log Parser template allows you to check a specified log file and determine the total number of lines that match your search criteria.

Prerequisites

Perl must be installed on the target server.

Credentials

Root on target server.

Component Arguments and Syntax

These three arguments are used in the following order: perl ${SCRIPT} "LogFilePath" "RegularExpression" "Position"

  1. Log file path – This is the path of the log file on the target server. The path can contain spaces, as opposed to the PowerShell template, which cannot.
  2. Regular Expression – This is used for regular expression searches to find a desired string in the log file. Searches are case sensitive and can contain spaces, as opposed to the PowerShell template, which cannot.
  3. 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.

Below is an example using the Command Line field used in the Number of Newly found strings component monitor. This example returns the number of newly found strings that match word init from the /etc/inittab file.

perl ${SCRIPT} "/etc/inittab" "init"

Monitored Components

For details on monitors, see SAM Component Monitor Types.

Total Number of Strings Found

This monitor shows the total number of strings that match the search criteria in the entire log file. Additionally, in the message field, this monitor returns all strings that match search criteria.

Below is an example using the Command Line field:
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. Additionally in message field this monitor returns all strings that matches search criteria.

Below is an example using the Command Line field:
perl ${SCRIPT} "/etc/inittab" "init" "0"

Found String in # Position

This monitor shows the number position of the string found from the end that matches the search criteria, as well as the string itself. By default, this counter also shows the last string.

Below is an example using the Command Line field. The Position argument is employed as “1”.
perl ${SCRIPT} "/etc/inittab" "init" "1"