Thursday, February 18, 2010

Nagios and HTTPS Monitoring

This doesn't seem to be configured in the basic Nagios installation, but it is easy to do. The following was done on a server running RedHat 5.2.

  1. Go to your nagios top level directory, /usr/local/nagios.
  2. Use the check_http command line tool and make sure it works:  ./libexec/check_http -H your.server.hostname -p 8443 -S   Here the port is 8443.  -S is the option to use SSL.
  3. Add a command, "check_https", to your etc/objects/commands.cfg file:

                     # 'check_https' command definitiondefine command{
                             command_name    check_https
                             command_line    $USER1$/check_http -I $ARG1$ -p $ARG2$ -S
                     }

  4. Add the host to be checked to the appropriate config file (see my previous post for an example, or see below).

  5. Make sure your don't have any typos: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

  6. Reload nagios: /etc/rc.d/init.d/nagios reload

You are done.  I put all of my Nagios checks into localhost.cfg, which is probably not a good idea, but it was simple to get going.  Add the following to the bottom of your cfg file:

define host{

        use             linux-server            ; Name of host template to use

        host_name      some-host  ; The name we're giving to this host

        alias           Some Host to Check  ; A longer name associated with the host

        address         123.456.789            ; IP address of the host

        hostgroups      linux-servers           ; Host groups this host is associated with

        }

define service{
        use             local-service         ; Name of service template to use

        host_name       some-host

        service_description     HTTP

        check_command   check_https!your.server.hostname!8443

        notifications_enabled           1

        }

1 comment:

Unknown said...

Hi,

You should look at Shinken, it’s a enhanced Nagios reimplementation in Python that allow you to have a quick and easy distributed and high availability monitoring environment, and of course with Nagios configuration and plugins compatibility :)

It's available (Open Source with a AGPL licence) at http://www.shinken-monitoring.org with even a demo virtual machine to test it in 5minutes :)


Jean gabès, Shinken developper