Need plugin for check on log-file

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Need plugin for check on log-file

Postby welbp00 » Wed Jun 12, 2019 4:22 am

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

Re: Need plugin for check on log-file

Postby scottwilkerson » Wed Jun 12, 2019 12:11 pm

Where did you get this plugin?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Need plugin for check on log-file

Postby welbp00 » Wed Jun 12, 2019 1:15 pm

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

Postby welbp00 » Wed Jun 12, 2019 1:20 pm

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

Re: Need plugin for check on log-file

Postby scottwilkerson » Wed Jun 12, 2019 4:46 pm

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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Need plugin for check on log-file

Postby welbp00 » Thu Jun 13, 2019 1:32 am

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

Postby welbp00 » Thu Jun 13, 2019 1:34 am

Herby the plugin
Attachments
check_logfiles.txt
added the .txt, otherwise no upload possible..
(206.81 KiB) Downloaded 67 times
welbp00
 
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: Need plugin for check on log-file

Postby scottwilkerson » Thu Jun 13, 2019 7:07 am

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_logfiles/#description
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Need plugin for check on log-file

Postby welbp00 » Thu Jun 13, 2019 7:24 am

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

Re: Need plugin for check on log-file

Postby scottwilkerson » Thu Jun 13, 2019 7:47 am

Looks like you are missing a - on each argument

Code: Select all
./check_logfiles --logfile=/tmp/testlog --criticalpattern 'FAILURE'
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Next

Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 5 guests

cron