Nagios Setup on Ubuntu 14.04

Installation

First, on server01 install the nagios package. In a terminal enter:

sudo apt-get install nagios3 nagios-nrpe-plugin

You will be asked to enter a password for the nagiosadmin user. The user’s credentials are stored in /etc/nagios3/htpasswd.users. To change the nagiosadmin password, or add additional users to the Nagios CGI scripts, use the htpasswd that is part of the apache2-utils package.

For example, to change the password for the nagiosadmin user enter:

sudo htpasswd /etc/nagios3/htpasswd.users nagiosadmin

Configuration

  • First, create a host configuration file for server02. Unless otherwise specified, run all these commands on server01. In a terminal enter:
     sudo service nagios3 restart

In the above and following command examples, replace “server01”, “server02” 172.18.100.100, and 172.18.100.101 with the host names and IP addresses of your servers.

  • Next, edit /etc/nagios3/conf.d/server02.cfg:
    define host{
            use                     generic-host  ; Name of host template to use
            host_name               server02
            alias                   Server 02
            address                 172.18.100.101
    }
    
    # check DNS service.
    define service {
            use                             generic-service
            host_name                       server02
            service_description             DNS
            check_command                   check_dns!172.18.100.101
    }
  • Restart the nagios daemon to enable the new configuration:

     sudo service nagios3 restart

Check if your web site is up

You could use check_http to check your website is up on port 80, you could also using this plugin as well:

https://exchange.nagios.org/directory/Plugins/Websites,-Forms-and-Transactions/Check-website-response/details

You might encounter this error:

     sudo service nagios3 restart
  • It might happen if you did not install netcat.
  • To install netcat,using the following command
     sudo service nagios3 restart
     sudo service nagios3 restart

If the out put is not /usr/bin/nc, you need to replace the netcat location in the check_website_response.sh script. In my case it is /bin/netcat.

I place my check_website_response.sh under /usr/lib/nagios/plugins

     sudo service nagios3 restart

replace NETCAT=/usr/bin/nc with NETCAT=/bin/netcat

Restart the nagios server.

     sudo service nagios3 restart

Done.