check_log not outputting CRITICAL line content

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

check_log not outputting CRITICAL line content

Postby dhhh » Mon Aug 09, 2021 5:41 am

I'm trying to get the check_log plugin working on a simple application log file that checks for multiple errors in a single line but the Status Information field in the Nagios dashboard only outputs "(1)" and not the line that triggered the CRITICAL alert when it correctly detects one of the errors.

I have the following in the nrpe.cfg:
Code: Select all
command[check_blah_log_errors]=sudo /usr/lib64/nagios/plugins/check_log -F /foo/foot.log -O /foo/foo.log.old.nagios -q '.*`date +%Y-%m-%d`T.*error: error_string_1_here\|error_string_2_here\|error_string_3_here\|error_string_4_here'


What needs to change to fix this? I've read about splitting the four strings into four separate checks but I'm looking to do over a dozen checks on the same server and would prefer to not have to if possible.
dhhh
 
Posts: 6
Joined: Thu Mar 18, 2021 5:07 am

Re: check_log not outputting CRITICAL line content

Postby mcapra » Mon Aug 09, 2021 8:10 am

NRPE does not run commands in a shell (it uses popen), and subsequently cannot perform Bash substitution as you're attempting to do here:
Code: Select all
`date +%Y-%m-%d`


I can't say for certain if that's what is causing your issue, but it stands out.
Former Nagios employee
https://www.mcapra.com/
User avatar
mcapra
 
Posts: 3724
Joined: Thu May 05, 2016 3:54 pm

Re: check_log not outputting CRITICAL line content

Postby dhhh » Tue Aug 10, 2021 8:13 pm

mcapra wrote:NRPE does not run commands in a shell (it uses popen), and subsequently cannot perform Bash substitution as you're attempting to do here:

You're right. Removing that from the line helped make it work.

Interstingly, although my original post doesn't have it, I used bash substitution for the log file names with the date too and THAT actually doesn't break (maybe coz that takes place within the sudo command itself?).
dhhh
 
Posts: 6
Joined: Thu Mar 18, 2021 5:07 am


Return to Community Support

Who is online

Users browsing this forum: Majestic-12 [Bot] and 24 guests