Page 1 of 1

Problem with host checks -- host always UP

Posted: Tue Dec 24, 2019 9:44 am
by erichymowitz
I can't figure out what I did wrong.

I have my host defined:

Code: Select all

define host{
    use     windows-server  ; Inherit default values from a template
    host_name   honda   ; The name we're giving to this host
    address     ip.add.re.ss
    check_command ping-with-nc
    }
and I have my command defined

Code: Select all

define command{
        command_name    ping-with-nc
        command_line    /usr/bin/nc -z -w 2 $HOSTADDRESS$ 22 2>&1
        }
and when my host is down, the command fails

Code: Select all

$ nc -z -w 2 honda 22
$ echo $?
1
But in nagios, the host is listed as "UP"

Does the ping command need to generate output? As far as I can tell from the documentation https://assets.nagios.com/downloads/nag ... tions.html , all I need to do is return the correct status ... which should be happening as far as I can tell.

What am I missing?

Thanks.

Re: Problem with host checks -- host always UP

Posted: Thu Dec 26, 2019 7:40 am
by scottwilkerson
Nagios would run

Code: Select all

/usr/bin/nc -z -w 2 ip.add.re.ss 22 2>&1
echo $?

Re: Problem with host checks -- host always UP

Posted: Thu Dec 26, 2019 7:55 am
by erichymowitz
Yes ... and when I run that command, the exit code is 1.

Re: Problem with host checks -- host always UP

Posted: Thu Dec 26, 2019 8:06 am
by scottwilkerson
In your nagios.cfg is use_aggressive_host_checking set to 1?
If not return code of 1 will result in an UP state
https://assets.nagios.com/downloads/nag ... inapi.html

Re: Problem with host checks -- host always UP

Posted: Thu Dec 26, 2019 8:14 am
by erichymowitz
scottwilkerson wrote:In your nagios.cfg is use_aggressive_host_checking set to 1?
If not return code of 1 will result in an UP state
https://assets.nagios.com/downloads/nag ... inapi.html
Ah. Didn't know that. Indeed, that option is turned off.

Thank you very much. I hope I never have to find out if you're right :) but I'll make that change and see what happens next time my host dies.

Re: Problem with host checks -- host always UP

Posted: Thu Dec 26, 2019 8:17 am
by scottwilkerson
erichymowitz wrote:
scottwilkerson wrote:In your nagios.cfg is use_aggressive_host_checking set to 1?
If not return code of 1 will result in an UP state
https://assets.nagios.com/downloads/nag ... inapi.html
Ah. Didn't know that. Indeed, that option is turned off.

Thank you very much. I hope I never have to find out if you're right :) but I'll make that change and see what happens next time my host dies.
Sounds good.

I'm going to lock the thread, if you have an issue if and when it dies, feel free to open a new thread.

Locking