Icinga2 Hostalive check - On host basis not with Ipaddress base

Hi Team,

We have been using Icinga2 for on-prem monitoring… Servers always changes the ips dynamically & sometimes when we run the nslookup i see multiple ipaddresses… we have been following automation process something like script does the dig & return the ip on hostfile…

I am trying to apply hostalive service check based on Hostname not with ipaddress. Is there anyway icinga2 itself can ping the servername directly or check the servername? not with ipaddress?

Correct me if my question weird… I have the following items for hostalive service check… Can you please someone advise on this?

apply Service "hostalive" {
  check_command = "ping4"
  enable_notifications = false
  command_endpoint = host.vars.remote_client
  assign where host.vars.client_endpoint
  # assign where host.address // check is executed on the master node
}

apply Service "hostalive" {
  check_command = "ping4"
  enable_notifications = false
  command_endpoint = host.vars.client_endpoint
  assign where host.vars.client_endpoint
  # assign where host.address // check is executed on the master node
}

& My sample hostfile will be as shown below…

object Endpoint "################" {
}

object Zone "################" {
     endpoints = [ "################" ]
     parent = "master"
}


// Host Objects
object Host "################" {
    check_command = "hostalive"
    address = "#.#.#.#"
    vars.os="Windows"
// Custom Optional check - START
    vars.local_disks["/app Filesystem"] = {
       disk_partitions = "/app"
  }

#     vars.local_http_vhosts["http"] = {
#        http_uri = "/"
#   }
  vars.nscp_boot = false
    vars.notification["mail"] = {
        groups = [ "icingausers" ]
        users = [ "icingaadmin" ]
}
    vars.notification["sms"] = {
        users = [ "icingaadmin" ]
}

    vars.local_tcp_port["tcp"] ={
       tcp_port = "23"
       service_name = "Telnet Check"
       port_number = "Port 23"
  }
// Custom Optional Check - END
}

If you have DNS configured, you could use the FQDN of the host for the address attributes instead of using the IP address.

object Host "################" {
    check_command = "hostalive"
    address = "server.companyname.com"
    vars.os="Windows"
}

I thought i responded… thanks for your help… it was working…