Host showing DHCP check failing but service is up

  • Version used (icinga2 --version): (version: 2.12.3)
  • Operating System and version: CentOS 7 x86_64
  • Enabled features (icinga2 feature list): api checker ido-mysql mainlog notification
  • Icinga Web 2 version and modules (System - About) Monitoring module enabled, icingaweb2 v2.8.2
  • Config validation (icinga2 daemon -C)
[root@icinga2 enabledModules]# icinga2 daemon -C
[2021-02-03 01:20:59 +0000] information/cli: Icinga application loader (version: 2.12.3)
[2021-02-03 01:20:59 +0000] information/cli: Loading configuration file(s).
[2021-02-03 01:20:59 +0000] information/ConfigItem: Committing config item(s).
[2021-02-03 01:20:59 +0000] information/ApiListener: My API identity: icinga2.ursa.com
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 NotificationComponent.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 6 Hosts.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 Downtime.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 2 NotificationCommands.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 FileLogger.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 12 Notifications.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 IcingaApplication.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 13 HostGroups.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 CheckerComponent.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 3 Zones.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 Endpoint.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 IdoMysqlConnection.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 ApiUser.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 ApiListener.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 237 CheckCommands.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 3 TimePeriods.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 UserGroup.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 User.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 23 Services.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 5 ServiceGroups.
[2021-02-03 01:20:59 +0000] information/ConfigItem: Instantiated 1 ScheduledDowntime.
[2021-02-03 01:20:59 +0000] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars'
[2021-02-03 01:20:59 +0000] information/cli: Finished validating the configuration file(s).

Question: Hello everyone, I just configured the check_dhcp command for my single DHCP server. Below are the configs for each. The service check is passing and failing, as it says the host is down with the plugin out saying CRITICAL: No DHCPOFFERs were received. but when I click the host’s service it shows its working for the plugin output. I am unsure why its showing its down when it is also up and working. OK: Received 1 DHCPOFFER(s), 1 of 1 requested servers responded, requested address (10.0.1.220) was offered, max lease time = 600 sec.

services.conf

apply Service "dhcp" {
  import "generic-service"

  check_command = "dhcp-server"
  vars.v = ""
  vars.u = ""
  vars.requested_ip = "<IP>"
  vars.dhcp_server = "<IP>"
  vars.dhcp_timeout = "20"
  vars.interface = "eth0"
  vars.dhcp_mac = "<Systems Mac Address>"

  assign where host.vars.dhcp == true
}

**commands.conf **

object CheckCommand "dhcp-server" {
  import "plugin-check-command"
  command = [ PluginDir + "/check_dhcp" ]
  arguments ={
  "-r" = "$requested_ip$"
  "-s" = "$dhcp_server$"
  "-t" = "$dhcp_timeout$"
  "-i" = "$interface$"
  "-m" = "$dhcp_mac$"
  "-v" = "$v$"
  "-u" = "$u$"
}
}

hosts.conf

object Host "dhcp.ursa.com" {
   import "generic-host"
   address = "dhcp.ursa.com"
   check_command = "hostalive"
   check_command = "dhcp"
   vars.os = "Linux"
   vars.dhcp = true
}

A host object should only have one host check command - your hosts.conf has defined two commands (your DHCP check and a hostalive/ping check).

See this page - Object Types - Icinga 2

I imagine the reason it is failing is you are applying the DHCP check as a service, and it is receiving the DHCP response, but when the host check executes, it does not receive a response because the DHCP server has already sent it (and it was received by the service check).

1 Like

The dhcp check simply overrides the hostalive as it is configured later.

The problem is the dhcp server will not offer a address to itself, so the check has to be run on a different system. I typically pick one suitable machine to execute the dhcp check, create endpoint and zone for it manually, assign the dhcp check to the dhcp server and then via command line I set the command_endpoint for the service to the endpoint I want the check to be executed on. So I get a result and the service is still shown on the dhcp server.

2 Likes

Thank you Liam! You were correct, having the dhcp check command and the vars.dhcp = true was a no go since, just defining it in the services.conf fixed it and keeping the vars.dhcp = true was good. Thanks so much!!!