Page 1 of 1

[SOLVED]testing negated plugin output

Posted: Tue Apr 05, 2016 8:40 am
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

Re: testing negated plugin output

Posted: Tue Apr 05, 2016 2:17 pm
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

Re: testing negated plugin output

Posted: Wed Apr 06, 2016 4:39 am
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

Re: [SOLVED]testing negated plugin output

Posted: Wed Apr 06, 2016 9:02 am
by lmiltchev
I am glad your issue has been resolved!