Page 1 of 1

How to force FQDN for host ping check ?

Posted: Thu Apr 06, 2017 12:05 pm
by nagmoto
I have host defined as following, and ip was out of sync with DNS server.
And this trigger an host down alert.

Code: Select all

define host{
        use                    windows-server
        host_name         cxa63.test.com
        alias                  cxa63.test.com
        address              10.4.122.83
        }
Question is how can I force Nagios 4.1.1 server to use host_name as 1st priority line to check for IP up/down ?

Re: How to force FQDN for host ping check ?

Posted: Thu Apr 06, 2017 2:14 pm
by mcapra
If we were to look at a very typical check_ping command definition, like the one used in Nagios XI, $HOSTADDRESS$ is used as part of the command_line parameter:

Code: Select all

define command {
       command_name                  		check_ping
       command_line                  		$USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}
You could instead $HOSTNAME$ in the command_line parameter, though that is a bit counter intuitive since you could just set the address for the host to the FQDN:

Code: Select all

define command {
       command_name                  		check_ping_host_name
       command_line                  		$USER1$/check_ping -H $HOSTNAME$ -w $ARG1$ -c $ARG2$ -p 5
}
More on Nagios Core macros:
https://assets.nagios.com/downloads/nag ... olist.html

Re: How to force FQDN for host ping check ?

Posted: Thu Apr 06, 2017 2:15 pm
by tgriep
You can put the FDQN of the host in the address field instead of the IP address. It doesn't have to be an IP address in that field, a host name will work as well.
The Nagios process will do a DNS lookup if there is a host name and the check should work the way you want.

Re: How to force FQDN for host ping check ?

Posted: Wed Apr 12, 2017 7:07 am
by nagmoto
Thanks for the help. Please close this post.