[SOLVED]testing negated plugin output

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
sputnik1
Posts: 4
Joined: Tue Apr 05, 2016 8:22 am

[SOLVED]testing negated plugin output

Post by sputnik1 »

Hi all.

I'm trying to test the output of a negated plugin.

How can I see the actual negated output from the wrapped plugin?

At the moment the plugin still shows the original output.

I'd like to test this from the command-line first, to make sure this works as expected before editing the nagios configuration.

/usr/lib/nagios/plugins # ./check_http -I 192.168.3.11 -S -p 4040
HTTP OK: HTTP/1.1 302 Moved Temporarily - 889 bytes in 0.045 second response time |time=0.045459s;;;0.000000 size=889B;;;0
/usr/lib/nagios/plugins #
/usr/lib/nagios/plugins # ./negate --ok=WARNING ./check_http -I 192.168.3.11 -S -p 4040
HTTP OK: HTTP/1.1 302 Moved Temporarily - 889 bytes in 0.041 second response time |time=0.041162s;;;0.000000 size=889B;;;0


Regards,

keith

Got it now ;)

sysadmin:/usr/lib/nagios/plugins # ./check_http -I 192.168.3.11 -S -p 4042
HTTP CRITICAL: HTTP/1.1 500 Internal Server Error - 227 bytes in 0.040 second response time |time=0.039625s;;;0.000000 size=227B;;;0
sysadmin:/usr/lib/nagios/plugins #
sysadmin:/usr/lib/nagios/plugins # echo $?
2
sysadmin:/usr/lib/nagios/plugins #
sysadmin:/usr/lib/nagios/plugins # ./negate ./check_http -I 192.168.3.11 -S -p 4042
HTTP CRITICAL: HTTP/1.1 500 Internal Server Error - 227 bytes in 0.042 second response time |time=0.041964s;;;0.000000 size=227B;;;0
sysadmin:/usr/lib/nagios/plugins #
sysadmin:/usr/lib/nagios/plugins # echo $?
0
Last edited by sputnik1 on Wed Apr 06, 2016 4:41 am, edited 1 time in total.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: testing negated plugin output

Post by lmiltchev »

You can also substitute the text (in CAPITALS) by passing "-s".

Example:
./negate --ok=WARNING -s ./check_http -I 192.168.3.11 -S -p 4040
Be sure to check out our Knowledgebase for helpful articles and solutions!
sputnik1
Posts: 4
Joined: Tue Apr 05, 2016 8:22 am

Re: testing negated plugin output

Post by sputnik1 »

Thanks for that tip miltchev ;)

I have got this working now by adding the following to my /etc/nagios/objects/commands.cfg file:

# 'negate_check_http' command definition
define command{
command_name negate_check_http
command_line $USER1$/negate --critical=OK "/usr/lib/nagios/plugins/check_http -I $HOSTADDRESS$ $ARG1$"
}


and then calling the modified negate_http_check from the relevant service definition in:

/etc/nagios/nagios.cfg.d/servers/services/https.cfg

define service{
host_name xxxxxx
service_description HTTPS - 4042

check_command negate_check_http! -S -p 4042
initial_state u


Regards,

Keith
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: [SOLVED]testing negated plugin output

Post by lmiltchev »

I am glad your issue has been resolved!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked