1. Place the "check_log3.exe" file in the NSClient++ scripts directory.
2. Define a command in the nsclient.ini (under [/settings/external scripts/scripts] section):
Code: Select all
check_log3 = scripts\check_log3.exe -l "c:\test.log" -p "failed"3. Test it from the CLI:
Code: Select all
[root@testbox libexec]# ./check_nrpe -H x.x.x.x -c check_log3
WARNING: Found 14757 lines (limit=1/0): 2015-05-13 15:58:51: error:D:\source\nscp\modules\CheckSystem\check_pdh.cpp:242: Exception in Failed to poll counter: \LogicalDisk(D:)\%Free Space PdhAddCounter failed: c0000bb9: The specified counter cou|'lines'=14757d.Code: Select all
./check_nrpe -H x.x.x.x -c check_log3 -a 'arg1 arg2...'Code: Select all
check_log3.pl version 3.5a
Usage: check_log3.pl [ -h | --help ]
Usage: check_log3.pl [ -v | --version ]
Usage: check_log3.pl -l log_file -s seek_file -p pattern | -P patternfile
[ -n negpattern | -f negpatternfile ]
[ -e '{ eval block}' | -E filename ]
[ --ok ] | ( [ -w warn_count ] [ -c crit_count ] )
[ -i ] [-d | -D ] [ -1 ] [ --context=[-|+]nn ]
This plugin scans arbitrary log files for regular expression matches.
-l, --logfile=<logfile>
The log file to be scanned.
-s, --seekfile=<seekfile>
The temporary file to store the seek position of the last scan.
-p, --pattern=<pattern>
The regular expression to scan for in the log file.
-i, --case-insensitive
Do a case insensitive scan.
-P, --patternfile=<filename>
File containing regular expressions, one per line, which will be combined
into an expression of the form 'line1|line2|line3|...'.
-n, --negpattern=<negpattern>
The regular expression to skip in the log file.
-f, --negpatternfile=<negpatternfile>
Specifies a file with regular expressions which all will be skipped.
-w, --warning=<number>
Return WARNING if at least this many matches found. The default is 1.
-c, --critical=<number>
Return CRITICAL if at least this many matches found. The default is 0,
i.e. don't return critical alerts unless specified explicitly.
-d, --nodiff-warn
Return WARNING if the log file was not written to since the last scan.
-D, --nodiff-crit
Return CRITICAL if the log was not written to since the last scan.
-1, --stop-first-match
Stop at the first line matched, instead of the last one.
--context=[-|+]<number>
Output <number> lines of context before or after matched line; use -N for
N lines before the match, +N for N lines after the match (if possible) or
an unqualified number to get N lines before and after the match.
--ok
Always return an OK status to Nagios.
-e, --parse
-E, --parse-file
Perl 'eval' block to parse each matched line with (EXPERIMENTAL). The code
should be in curly brackets and quoted. If the return code of the block is
non-zero, the line is counted against the threshold; otherwise it isn't.