Page 1 of 2

Need plugin for check on log-file

Posted: Wed Jun 12, 2019 4:22 am
by welbp00
Hello,
I am trying to get a nagios plugin working for searching a word (SUCCESS) in a logfile.
I have downloaded the pluging check_log. I don't understand how to get it working.

check_logfile v1.0.0 (nagios-plugins 2.0.3)

Usage:
check_logfile [options] <regexp>[ <regexp>[ <regexp[ ...]]]
Options:
-f, --file <FILE> Logfile to search
-x, --exitcode <CODE> Code to exit with if match successful
-i, --invert Invert match expression (found == fail, not found = success)
-s, --start-at <LINE> Line number to start looking from
-v, --verbose Verbose output
-V, --version Show version and exit
-h, --help Show usage information and exit
Log file pattern detector plugin for Nagios

-bash-4.2# ./check_logfile -f /tmp/testlog -i -s 1 grep SUCCESS
0 matches found from 0 expression(s)
- no matches found for expression 'grep'
- no matches found for expression 'SUCCESS'

-bash-4.2# ./check_logfile -f /tmp/testlog -i -s 1 "Finished: SUCCESS"
0 matches found from 0 expression(s)
- no matches found for expression 'Finished: SUCCESS'
-bash-4.2# ./check_logfile -f /tmp/testlog -i -s 1 /Finished: SUCCESS/
0 matches found from 0 expression(s)
- no matches found for expression '/Finished:'
- no matches found for expression 'SUCCESS/'

I am not familiar with the regex... I must be doing something wrong..

Any help would be nice.

Regards, Paul.

Re: Need plugin for check on log-file

Posted: Wed Jun 12, 2019 12:11 pm
by scottwilkerson
Where did you get this plugin?

Re: Need plugin for check on log-file

Posted: Wed Jun 12, 2019 1:15 pm
by welbp00
scottwilkerson wrote:Where did you get this plugin?

https://labs.consol.de/nagios/check_log ... escription

Re: Need plugin for check on log-file

Posted: Wed Jun 12, 2019 1:20 pm
by welbp00
welbp00 wrote:
scottwilkerson wrote:Where did you get this plugin?

https://labs.consol.de/nagios/check_log ... escription
But if you know another one.... What i need: to check several directory's, into some logs, checking a keyword like failure.
That should give a warning

Re: Need plugin for check on log-file

Posted: Wed Jun 12, 2019 4:46 pm
by scottwilkerson
I'm confused because there version on that site is check_logfiles-3.11.0.2 and you showed a version of 1.0.0

also the command line arguments on the page are way different than what you showed

Code: Select all

    --tag=<identifier> A short unique descriptor for this search. It will appear in the output of the plugin and is used to separare the different services.
    --logfile=<filenname> This is the name of the log file you want to scan.
    --rotation=<method> This is the method how log files are rotated.
    --criticalpattern=<regexp> A regular expression which will trigger a critical error.
    --warningpattern=<regexp> The same…a match results in a warning.
    --criticalexception=<regexp> / –warningexception=<regexp> Exceptions which are not counted as errors.
    --okpattern=<regexp> A pattern which resets the error counters.
    --noprotocol Normally all the matched lines are written into a protocol file with this file’s name appearing in the plugin’s output. This option switches this off.
    --syslogserver With this option you limit the pattern matching to lines originating from the host check_logfiles is running on.
    --syslogclient=<clientname> With this option you limit the pattern matching to lines originating from the host named in this option.
    --sticky[=<lifetime>] Errors are propagated through successive runs.
    --unstick Resets sticky errors.
    --config The name of a configuration file. The syntax of this file is described in the next section.
    --configdir The name of a configuration directory. Configfiles ending in .cfg or .conf are (recursively) imported.
    --searches=<tag1,tag2,…> A list of tags of those searches which are to be run. Using this parameter, not all searches listed in the config file are run, but only those selected. (–selectedsearches is also possible)
    --report=[short|long|html]This option turns on multiline output (Default: off). The setting html generates a table which display the last hits in the service details view.
    --maxlength=[length] With this parameter long lines are truncated (Default: off). Some programs (e.g. TrueScan) generate entries in the eventlog of such a length, that the output of the plugin becomes longer than 1024 characters. NSClient++ discards these.
    --winwarncrit With this parameter messages in the eventlog are classified by the type WARNING/ERROR (Default: off). Replaces or complements warning/criticalpattern.
    --rununique This parameter prevents check_logfiles from starting when there’s already another instance using the same config file. (exits with UNKNOWN)
    --timeout=<seconds>. This parameter causes an abort of a running search after a defined number of seconds. It is an aborted in a controlled manner, so that the lines which have been read so far, are used for the computation of the final result.
    --warning=<Number>. Complex handler-scripts can be provided with a warning-parameter (of course –critical is possible, too) this way. Inside the scripts the value is accessible as the macro CL_WARNING (resp. CL_CRITICAL).
Are you sure that's where you downloaded it from? Can you upload the plugin you have to the forum?

Re: Need plugin for check on log-file

Posted: Thu Jun 13, 2019 1:32 am
by welbp00
Sorry, the first item i posted is different from the last one....

This is the one i am working with: https://labs.consol.de/nagios/check_log ... escription

I will upload the plugin.

Re: Need plugin for check on log-file

Posted: Thu Jun 13, 2019 1:34 am
by welbp00
Herby the plugin

Re: Need plugin for check on log-file

Posted: Thu Jun 13, 2019 7:07 am
by scottwilkerson
So this file returns completely different output than the plugin you posted above, where you posted:
welbp00 wrote:check_logfile v1.0.0 (nagios-plugins 2.0.3)

Usage:
check_logfile [options] <regexp>[ <regexp>[ <regexp[ ...]]]
Options:
-f, --file <FILE> Logfile to search
-x, --exitcode <CODE> Code to exit with if match successful
-i, --invert Invert match expression (found == fail, not found = success)
-s, --start-at <LINE> Line number to start looking from
-v, --verbose Verbose output
-V, --version Show version and exit
-h, --help Show usage information and exit
Log file pattern detector plugin for Nagios

-bash-4.2# ./check_logfile -f /tmp/testlog -i -s 1 grep SUCCESS
0 matches found from 0 expression(s)
- no matches found for expression 'grep'
- no matches found for expression 'SUCCESS'

-bash-4.2# ./check_logfile -f /tmp/testlog -i -s 1 "Finished: SUCCESS"
0 matches found from 0 expression(s)
- no matches found for expression 'Finished: SUCCESS'
-bash-4.2# ./check_logfile -f /tmp/testlog -i -s 1 /Finished: SUCCESS/
0 matches found from 0 expression(s)
- no matches found for expression '/Finished:'
- no matches found for expression 'SUCCESS/'
Did you try using the arguments as outlined here?
https://labs.consol.de/nagios/check_log ... escription

Re: Need plugin for check on log-file

Posted: Thu Jun 13, 2019 7:24 am
by welbp00
I get this:

-bash-4.2# ./check_logfiles -logfile=/tmp/testlog -criticalpattern 'FAILURE'
OK - no errors or warnings|'default_lines'=0 'default_warnings'=0 'default_criticals'=0 'default_unknowns'=0


cat /tmp/testlog
PLAY RECAP *********************************************************************
pr7p0173.prod.server.nl : ok=4 changed=1 unreachable=0 failed=0

Finished: FAILURE

Re: Need plugin for check on log-file

Posted: Thu Jun 13, 2019 7:47 am
by scottwilkerson
Looks like you are missing a - on each argument

Code: Select all

./check_logfiles --logfile=/tmp/testlog --criticalpattern 'FAILURE'