Problem with host checks -- host always UP

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
erichymowitz
Posts: 10
Joined: Thu Aug 18, 2016 11:18 am

Problem with host checks -- host always UP

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Problem with host checks -- host always UP

Post by scottwilkerson »

Nagios would run

Code: Select all

/usr/bin/nc -z -w 2 ip.add.re.ss 22 2>&1
echo $?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
erichymowitz
Posts: 10
Joined: Thu Aug 18, 2016 11:18 am

Re: Problem with host checks -- host always UP

Post by erichymowitz »

Yes ... and when I run that command, the exit code is 1.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Problem with host checks -- host always UP

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
erichymowitz
Posts: 10
Joined: Thu Aug 18, 2016 11:18 am

Re: Problem with host checks -- host always UP

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Problem with host checks -- host always UP

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked