How to force FQDN for host ping check ?

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
nagmoto
Posts: 195
Joined: Fri Jan 09, 2015 8:05 am

How to force FQDN for host ping check ?

Post 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 ?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: How to force FQDN for host ping check ?

Post 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
Former Nagios employee
https://www.mcapra.com/
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: How to force FQDN for host ping check ?

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
nagmoto
Posts: 195
Joined: Fri Jan 09, 2015 8:05 am

Re: How to force FQDN for host ping check ?

Post by nagmoto »

Thanks for the help. Please close this post.
Locked