Page 1 of 1

Status return nagios plugins using sed

Posted: Thu Aug 29, 2019 2:28 am
by fernando974
Hello,

I have a plugin in nagios "check_icmp" who return 4 values if the command can ping the demanded host however i got only 1 values if the ping failed so i used the following command :

so i used the following command :

Code: Select all

/usr/lib64/nagios/plugins/check_icmp -w 1000.0,20% -c 1400.0,60% -H 8.8.4.5 -m 5 | sed 's/pl=100%;20;60;0;100/rta=nan;;;; rtmax=nan;;;; rtmin=nan;;;; pl=100%;20;60;0;100/g'
and it returns

Code: Select all

CRITICAL - 8.8.4.5: rta nan, lost 100%|rta=nan;;;; rtmax=nan;;;; rtmin=nan;;;; pl=100%;20;60;0;100
instead of

Code: Select all

CRITICAL - 8.8.4.5: rta nan, lost 100%|pl=100%;20;60;0;100
so it works great on the host but if i put this command in nagiosql the current status stay in green "OK" even if the ping failed :

https://ibb.co/LCzvXrV

Re: Status return nagios plugins using sed

Posted: Thu Aug 29, 2019 12:40 pm
by mcapra
http://nagios-plugins.org/doc/guidelines.html

Piping into sed is going to overwrite the exit code that was returned by the check_icmp plugin. You're seeing "OK" because your final sed command in the chain is returning 0 for the exit code. Your Bash logic should include something to make sure the exit code of your check_icmp call is preserved through the entire execution and represents the final exit code.

An example of this:
https://unix.stackexchange.com/question ... -for-later

Re: Status return nagios plugins using sed

Posted: Thu Aug 29, 2019 4:49 pm
by mbellerue
Thanks for jumping in, mcapra!

fernando974, does mcapra's response help with your issue?

Re: Status return nagios plugins using sed

Posted: Mon Sep 02, 2019 2:25 am
by fernando974
Thanks i solved my problem ! :)

Re: Status return nagios plugins using sed

Posted: Tue Sep 03, 2019 7:22 am
by scottwilkerson
fernando974 wrote:Thanks i solved my problem ! :)
Great!

Locking thread