cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

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.


Note: You must specify the correct arguments for each monitored component in the Script Arguments field. If you fail to do this, the monitor will return with a status error of "Undefined."


Components Monitors with Examples

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. In the returning message, this component returns all lines that match the search criteria divided by ";"

       This monitor uses the following arguments:
      perl ${SCRIPT} LogFilePath RegularExpression
     
where
      LogFilePath -
This is the path of the target log file on the target server. The path can contain spaces.
      RegularExpression -
This is used for regular expression searches to find a desired string in the log file. Searches are case sensitive and can contain spaces.

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

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. In the returning message, this component returns all lines that match the search criteria divided by ";"

      This monitor uses the following arguments:
     perl ${SCRIPT} LogFilePath RegularExpression
     
where
      LogFilePath -
This is the path of the target log file on the target server. The path can contain spaces.
      RegularExpression -
This is used for regular expression searches to find a desired string in the log file. Searches are case sensitive and can contain spaces.

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

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.

     This monitor uses the following arguments:
     perl ${SCRIPT} LogFilePath RegularExpression
     
where
      LogFilePath -
This is the path of the target log file on the target server. The path can contain spaces.
      RegularExpression -
This is used for regular expression searches to find a desired string in the log file. Searches are case sensitive and can contain spaces.
     Position - This value determines the position from the last string of the log file. By default value 1 will return last found string.

    

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

Labels (1)
Attachments
Comments
How do you install this?
Download the template and import it into APM through the web interface. Alternatively you can go to Settings -> APM Settings -> Shared thwack Templates -> Select the template -> Click "Import"

Dear aLTeReGo,

Thank you, possible to alter the Perl script to return a string of message after finding the keyword ?

Similar to the one create by Mike which is in PowerShell script ?

Thanks

Regards

Max

We're considering updating this application template to do just that. It's currently being tracked as FB125687

The latest version of this application template now returns the full line of text where the  string was found.

If I wanted to search for multiple keywords would the format be like this?

perl ${SCRIPT} LogFilePath "<keyword1|keyword2|keyword3|....."

I am trying to configure this log parser against an oracle alert log, which can get fairly large.  This was working fine as I had some alerts going against Newly Found strings.

Then we went ahead and we purged the log.  This seems to have caused issues.  I am guessing that there is some type of in-memory array that has a high number in it, and this number is staying that high.  Say there was 200 strings of ORA- in the file.  It was then purged, and now there is 0.  So I think the array is waiting for more than 200, where there is actually now 0.

HOw does this reset to properly handle finding new strings after the file is purged?

How can I runt his perl script as root?

I have been trying to use the application template to monitor Apache Log /etc/httpd/logs/error_log, now I notice I am not able to run the script against this but if it is some other file am able to get the output which seems to be permission issue.

I am trying to use the template, but it returns "Timeout while executing job", I am not sure why this is happening. Is it because I am looking at 623M log file?

Version history
Revision #:
1 of 1
Last update:
‎06-29-2011 12:00 AM