Status return nagios plugins using sed

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.
Locked
fernando974
Posts: 2
Joined: Thu Aug 29, 2019 2:20 am

Status return nagios plugins using sed

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Status return nagios plugins using sed

Post 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
Former Nagios employee
https://www.mcapra.com/
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: Status return nagios plugins using sed

Post by mbellerue »

Thanks for jumping in, mcapra!

fernando974, does mcapra's response help with your issue?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
fernando974
Posts: 2
Joined: Thu Aug 29, 2019 2:20 am

Re: Status return nagios plugins using sed

Post by fernando974 »

Thanks i solved my problem ! :)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Status return nagios plugins using sed

Post by scottwilkerson »

fernando974 wrote:Thanks i solved my problem ! :)
Great!

Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked