passive host check return code "0"

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
lesnikov
Posts: 28
Joined: Sat Jan 19, 2013 10:40 pm
Location: Slovenia

passive host check return code "0"

Post by lesnikov »

hi.

I'm having problems with nagios passive host checks. Every host state is sent to central server as "0" even if it is warning or critical. Service state has no problem, works like it should.

log from central nagios server
Host check

Code: Select all

Jun 24 17:00:46 srv-nag1 nagios: EXTERNAL COMMAND: PROCESS_HOST_CHECK_RESULT;HS-ai117;0;CRITICAL - Host Unreachable (10.41.12.117)
Jun 24 17:00:53 srv-nag1 nagios: PASSIVE HOST CHECK: HS-ai117;0;CRITICAL - Host Unreachable (10.41.12.117)
service check from central nagios server

Code: Select all

Jun 23 03:57:55 srv-nag1 nagios: EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;HS-ai119;ai119;1;Warning: ai119 has a modified date of Sun 22 Jun/2014 13:20
Jun 23 03:57:58 srv-nag1 nagios: PASSIVE SERVICE CHECK: HS-ai119;ai119;1;Warning: ai119 has a modified date of Sun 22 Jun/2014 13:20
submit host check script from slave nagios server

Code: Select all

#!/bin/bash
# Host Check
cmd="/usr/local/nagios/bin/send_nsca"
cfg="/usr/local/nagios/etc/send_nsca.cfg"
host=$1
result=$2
output=$3
/bin/echo -e "$host\t$result\t$output\n" | $cmd -H 10.50.12.200 -c $cfg
submit service check script from slave nagios server

Code: Select all

#!/bin/bash
# Service Check
cmd="/usr/local/nagios/bin/send_nsca"
cfg="/usr/local/nagios/etc/send_nsca.cfg"
host=$1
srv=$2
result=$3
output=$4
/bin/echo -e "$host\t$srv\t$result\t$output\n" | $cmd -H 10.50.12.200 -c $cfg
nagios.cfg nagios slave server

Code: Select all

obsess_over_services=1
ocsp_command=service_check
ocsp_timeout=5
obsess_over_hosts=1
ochp_command=host_check
ochp_timeout=5
commands.cfg from nagios slave server

Code: Select all

define command{
command_name service_check
command_line $USER1$/eventhandlers/service_check $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATEID$ '$SERVICEOUTPUT$'
}
define command{
command_name host_check
command_line $USER1$/eventhandlers/host_check $HOSTNAME$ $SERVICESTATEID$ '$HOSTOUTPUT$'
}
Best ragards
Last edited by lesnikov on Wed Jun 25, 2014 4:06 pm, edited 1 time in total.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: passive host check return code "0"

Post by tmcdonald »

What is running on the passive/remote hosts that is ultimately sending the results via send_nsca? Is it a home-brew script of some sort? Have you verified that it is in fact exiting with the proper code?
Former Nagios employee
lesnikov
Posts: 28
Joined: Sat Jan 19, 2013 10:40 pm
Location: Slovenia

Re: passive host check return code "0"

Post by lesnikov »

Ok, I edited first post and entered slave/master on top of code.
So on passive/remote we run nagios server. Results are sent to main nagios server over ocsp_command, ochp_command.
On slave server everything looks fine host states are shown as they should be, UP,DOWN... But they are all transmitted to central server as state 0 (host up).
lesnikov
Posts: 28
Joined: Sat Jan 19, 2013 10:40 pm
Location: Slovenia

Re: passive host check return code "0"

Post by lesnikov »

You can close topic. I fixed it with editing host_check script on slave server:

commands.cfg

Code: Select all

define command{
command_name host_check
command_line $USER1$/host_check  $HOSTNAME$ $HOSTSTATEID$ '$HOSTOUTPUT$|$HOSTPERFDATA$'
}
host_check

Code: Select all

#!/bin/bash
# host check
cmd="/usr/local/nagios/bin/send_nsca"
cfg="/usr/local/nagios/etc/send_nsca.cfg"
host=$1
srv=$2
result=$3
output=$4
/bin/echo -e "$host\t$srv\t$result\t$output\n" | $cmd -H 10.50.12.200 -c $cfg
Locked