Log Parser

Version 3

    This template looks for a specified keyword in the log files of a specified directory and its subdirectories on a Linux or Unix computer and lists the number of occurrences along with the lines where the keyword is present.

     

    Prerequisites: SSH and Perl installed on the target server.

    Credentials: Root user on the target server.

     

    Monitored Components

    Number of Matches

    This monitor returns the number of times the keyword appeared in the log file(s) of a specified directory and its subdirectories.

    Note: Before using this monitor, the correct argument should be set. This monitor requires the following arguments:

     

    perl ${SCRIPT} keyword directory file/filepattern
    where
    keyword – the keyword to search for.
    directory – the directory where log files are present.
    file/filepattern – File to be searched for or a group of files specified by a wildcard pattern within double quotes, like "*.log".

     

    Examples:

    perl ${SCRIPT} rtdata /opt/Storage_Manager_Agent/systemic/mod.sys.asset.Asset_1.0/ mod.sys.asset.Asset.log

    perl ${SCRIPT} Exception /opt/Storage_Manager_Agent/systemic/ "*.log*"

     

    Matching Lines

    This monitor returns lines where the keyword was found in the log file(s) of a specified directory and its subdirectories.

    Note: Before using this monitor, the correct arguments should be set. This monitor requires the same arguments as in the component above.

     

    Comment

    I wanted to create a template which allows searching through log files by wildcard patterns and recursively into subdirectories as well, which didn't seem to be an option in the inbuilt "Log Parser (Perl)" template in SAM.