Log Parser with Matches

Version 3

    This template searches through the specified file in a specified server and returns the count of matches along with line number and position of the first nine occurrences of the specified search pattern.

    Prerequisites: WMI access to the target server.

    Credentials: Windows Administrator on the target server.

    Note: Tested on Windows Server 2008 R2 and Windows Server 2012 R2

    MONITORED COMPONENTS:

    This component looks through specified file for the specified pattern (regular expression) and lists the number of matches.

    The subsequent nine return values display the line numbers, the position and part of the pattern match found in each line of the text file.

    Since it is a search pattern and not a search string, you could also list the line where the match is present by including .+ at end or beginning of the pattern.

    Arguments: Remote server, filename to scan, search pattern to find (regular expression).

    For example, 10.100.100.25 "C:\Work\testfile.txt" "(email|phone).+"

    Make sure proper credentials are assigned and verify file access from the SAM server to avoid permission denied errors.

     

    Changes done on 20160726:

    - Added remote server as the first argument, followed by file to scan and pattern to search for.

    - Using WMI service ExecQuery against CIM_DataFile to check existence of file instead of FileSystemObject.

    - Using UNC path to access and read file contents.