Need plugin for check on log-file

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Need plugin for check on log-file

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Need plugin for check on log-file

Post by scottwilkerson »

Where did you get this plugin?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: Need plugin for check on log-file

Post by welbp00 »

scottwilkerson wrote:Where did you get this plugin?

https://labs.consol.de/nagios/check_log ... escription
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: Need plugin for check on log-file

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Need plugin for check on log-file

Post 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?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: Need plugin for check on log-file

Post 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.
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: Need plugin for check on log-file

Post by welbp00 »

Herby the plugin
Attachments
check_logfiles.txt
added the .txt, otherwise no upload possible..
(206.81 KiB) Downloaded 248 times
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Need plugin for check on log-file

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: Need plugin for check on log-file

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Need plugin for check on log-file

Post by scottwilkerson »

Looks like you are missing a - on each argument

Code: Select all

./check_logfiles --logfile=/tmp/testlog --criticalpattern 'FAILURE'
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked