check_http result not as expected

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
wilcoNL
Posts: 4
Joined: Thu Jan 06, 2011 11:06 am

check_http result not as expected

Post by wilcoNL »

Hello,

I have a slight problem with the check_http result with my nagios.

I try to check a certain page with the check_http command. When I try it on the command line it gives me back the correct result. Also within a batch program echo $? gives 0 if ok and 2 if critical. All well here.

But when I use the command with nagios, I get a critical result, but the code for error allways gives me back a 0. So allways an OK.

PASSIVE SERVICE CHECK: NLHOLNAGIOS01;SYSTEM: MultiMedia;0;HTTP CRITICAL: HTTP/1.0 200 OK - string Keesje not found on http://bla die bla.nl

Above the strange result. HTTP Critical with a code 0.
I use nagios-plugins 1.4.15 and nagios 3.1.2
I use the command check_http -H <servername> -u <difficult uri> -s keesje

Has anybody seen this behaviour before?

Wilco
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: check_http result not as expected

Post by mguthrie »

Can you post the send_nsca command you're you're sending that with?
wilcoNL
Posts: 4
Joined: Thu Jan 06, 2011 11:06 am

Re: check_http result not as expected

Post by wilcoNL »

Hello,

We installed the standard NSCA commands as described in the documentation.

All other services return normal statusvalues.

It is a distributed environment at our customers. I thought Nagios took care of the send_nsca statements (as far as I know), I never changed them.

Code: Select all

define command{
    command_name    submit_check_result
    command_line    /appl/nagios/libexec/eventhandlers/submit_check_result_via_nsca $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ '$SERVICEOUTPUT$'
    }
If this is not what you wanted, plz give me a direction were to go and what you wanted to see.
wilcoNL
Posts: 4
Joined: Thu Jan 06, 2011 11:06 am

Re: check_http result not as expected

Post by wilcoNL »

Hello,

found new stuff in debugging file:

Code: Select all

 Running command '/appl/nagios/libexec/eventhandlers/submit_check_result_via_nsca NLHOLNAGIOS01 'SYSTEM: MultiMedia' CRITICAL 'HTTP CRITICAL: HTTP/1.0 200 OK - string Keesje not found on http://string bladibla.nl.....- 263 bytes in 0.018 second response time''...
Conclusion: sending string is OK.
But why is telling me on the other side that the CRITICAL became 0 ?!

Something at the Main Nagios implementation is going wrong?

Any ideas?

Wilco
wilcoNL
Posts: 4
Joined: Thu Jan 06, 2011 11:06 am

Re: check_http result not as expected

Post by wilcoNL »

Hello,

Found the problem.

The file submit_check_result_via_nsca submited the statuscodes as CRITICAL instead of the value of CRITICAL which is 2. So I added some code to the batch file and VOILA :shock:

I ended up with this code:

Code: Select all

#!/bin/sh

# SUBMIT_CHECK_RESULT_VIA_NSCA
# Written by Ethan Galstad (egalstad@nagios.org)
# Last Modified: 17-02-2011 (W. Groothand wgroothand@gmail.com)
#
# This script will send passive check results to the
# nsca daemon that runs on the central Nagios server.
# If you simply want to submit passive checks from the 
# same machine that Nagios is running on, look at the
# submit_check_result script.
#
# Arguments:
#  $1 = host_name (Short name of host that the service is
#       associated with)
#  $2 = svc_description (Description of the service)
#  $3 = return_code (An integer that determines the state
#       of the service check, 0=OK, 1=WARNING, 2=CRITICAL,
#       3=UNKNOWN).
#  $4 = plugin_output (A text string that should be used
#       as the plugin output for the service check)s
# 
#
# Note:
# Modify the NagiosHost parameter to match the name or
# IP address of the central server that has the nsca
# daemon running.

printfcmd="/usr/bin/printf"

NscaBin="/appl/nagios/bin/send_nsca" 
NscaCfg="/appl/nagios/etc/send_nsca.cfg"
NagiosHost="<IP ADDRESS>"
NagiosPort="<PORTNUMBER>"


Result=0

if [ $3 = "OK" ] ; then
        Result=0
fi
if [ $3 = "WARNING" ] ; then
        Result=1
fi
if [ $3 = "CRITICAL" ] ; then
        Result=2
fi
if [ $3 = "UNKNOWN" ] ; then
        Result=3
fi

# Fire the data off to the NSCA daemon using the send_nsca script
$printfcmd "%s\t%s\t%s\t%s\n" "$1" "$2" "$Result" "$4" | $NscaBin -H $NagiosHost -p $NagiosPort -c $NscaCfg

# EOF
rdedon
Posts: 578
Joined: Sat Nov 20, 2010 4:51 pm

Re: check_http result not as expected

Post by rdedon »

Thanks for the update and glad to see you got it working :-)
Rene deDon
Technical Team
___
Nagios Enterprises, LLC
Web: http://www.nagios.com
Locked