Status return nagios plugins using sed

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.

Status return nagios plugins using sed

Postby fernando974 » Thu Aug 29, 2019 2:28 am

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

Re: Status return nagios plugins using sed

Postby mcapra » Thu Aug 29, 2019 12:40 pm

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
http://www.mcapra.com/
User avatar
mcapra
 
Posts: 3584
Joined: Thu May 05, 2016 3:54 pm

Re: Status return nagios plugins using sed

Postby mbellerue » Thu Aug 29, 2019 4:49 pm

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!
User avatar
mbellerue
 
Posts: 808
Joined: Fri Jul 12, 2019 11:10 am

Re: Status return nagios plugins using sed

Postby fernando974 » Mon Sep 02, 2019 2:25 am

Thanks i solved my problem ! :)
fernando974
 
Posts: 2
Joined: Thu Aug 29, 2019 2:20 am

Re: Status return nagios plugins using sed

Postby scottwilkerson » Tue Sep 03, 2019 7:22 am

fernando974 wrote:Thanks i solved my problem ! :)

Great!

Locking thread
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: 16772
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 35 guests