Configuring Nagios check_http on Ubuntu

I'm writing this post as I do it. My starting point is a fresh install of Nagios 2 running on an ubuntu server in EC2. My goal is to get it monitoring some web pages. I've found poor documentation, so I'm writing this out as I go.

First, you must define the command you want to use (I think). Here's my definition:

define command {
       command_name	check_http_port
       command_line	$USER1$/check_http -h $ARG1$ -p $ARG2$
       }

This goes in /etc/nagios2/commands.cfg. Next, you have to create a file in /etc/nagios2/conf.d for the host you want monitored (or the group of hosts, or just a local.cfg in that directory). In this file you need to define your hosts, and any services you want monitored. Here I use the check_http_port command defined above to ping our frontend machine. Notice the odd syntax for providing parameters to the command.

define host{
        use                     generic-host
        host_name               mi-prod-web01
        alias                   mi-prod-web01
        }
define service{
        use                             generic-service
        host_name                       mi-prod-web01
        service_description             Login Page
	check_command                   check_http_port!mi-prod-app01!80
        }

Lastly, you probably want to add the host to host group in conf.d/

define hostgroup {
        hostgroup_name  http-servers
		alias           HTTP servers
		members         localhost,mi-prod-web01
        }