2

I recently implemented ISC DHCP Failover and it's working beautifully, but I'd like to monitor the current status of the failover using Nagios.

Ultimately, I would like my Nagios check to:

  • report a WARNING when the Secondary DHCP server kicks in (starts serving addresses due to an issue with the Primary)
  • report a CRITICAL when both the Primary and Secondary aren't active.
  • Monitoring the dhcpd process to see if it is running or not is unfortunately not the true solution -- a failover state can activate even when dhcpd is still running.

    From what I've researched, it appears dhcpd cannot be queried for a current status. Aside from parsing log files, does anyone know of a clean way to determine whether a dhcpd server is currently in a failover state or not?

    4 Answers 4

    2

    For monitoring a failover setup, I would use OMAPI commands (eg. via omshell) to check the status of the failover-state object.

    Considering you have properly configured your dhcpd server to enable OMAPI access, you could use something like:

    $ cat check-failover.cmd <<EOF
    server localhost
    port 7911
    key omapi_key <KEY>
    connect
    new failover-state
    set name = "<FAILOVER NAME>"
    open
    EOF
    

    Then use it like:

    $ omshell < check-failover.cmd | grep state
    partner-state = 00:00:00:02
    local-state = 00:00:00:02
    

    With state being an integer which value is described in dhcpd.8 man page (1 is "startup", 2 is "normal", etc.).

    It should be quite easy to write a Nagios/Shinken probe from this.

    1

    Did you consider simply checking on the protocol and just try to obtain a lease without configuring an interface using dhclient -n?

    You would be able to distinguish between the primary and secondary server by checking on the IP address of the server providing the lease which is printed to stderr by dhclient.

    0

    From what I could establish, you would have to use omshell. This is a wrapper for OMAPI calls, an API that can be used to communicate with a running DHCP server. The omshell is usually included in the dhcp server package (at least it was on my Debian linux box).

    However, it doesn't look like omshell easily accepts an input file. You might have to experiment a little.

    Once you have the omshell going, you will need to execute a remote shell command within nagios to run omshell and return the results to the nagios server.

    0

    It sounds like you need the Nagios Business Process Intelligence (BPI) add-on. This allows you to monitor a group of services and set alerts thresholds based on how many are up.

    Shinken has this functionality built-in, too.

    You can use the check_dhcp from Nagios Plugins to monitor DHCP -- it tries to get a lease from a specific server, and alerts if it doesn't. Together with BPI you should be able to achieve what you described.

    1
    • I considered check_dhcp, but check_dhcp still will only provide circumstantial evidence toward the case of a failover state being active. In other words, it's possible a server will/will not lease to check_dhcp for reasons other than a failover state. I'm looking for more direct evidence of the failover state. Thank you for the links to BPI and Shinken, however.
      – user81598
      May 17, 2011 at 13:34

    You must log in to answer this question.