Installing and Configuring Nagios Ubuntu 11.04


Nagios Logo

Nagios is the Industry Standard Network Monitoring Engine. OK great so what’s that mean, well Nagios is a server that monitors your hosts and services and will inform you if something goes wrong and when it is fixed again. It can monitor network services, host resources and even network probes such as temperature and moisture.

These features as well as many more make Nagios, by far, the most complete open-source Network Monitoring tool on the market, however with all these features comes complexity and Nagios has obviously been designed with the experienced Network Administrator in mind. But don’t worry too much, its not that difficult to learn as long as you take it one step at a time, and in today’s tutorial we’re going to look at the first step, actually getting it installed

So let’s get started, the first thing we need to install in LAMP as this is the base in which runs, simply type in the following command in your terminal and follow the onscreen commands:

sudo tasksel install lamp-server

For more information on LAMP you can view my complete LAMP server tutorial here

Now we need to install Nagios, to do this type:

sudo apt-get install -y nagios3

This will install and configure Nagios 3 along with any the required dependencies you don’t already have. It may ask for a few input parameters such as internet address and login password, just follow the onscreen guidelines and you should be fine.

If you have completed these stops correctly you should be able to view your Nagios dashboard by typing in the following in your web browser substituting [IP ADDR] for your servers IP address.

http://[IP ADDR]/nagios3/

You’ll need to enter a username and password. Your username will be ‘nagiosadmin’, the password will be the same as the one you entered during setup.

Username:nagiosadmin
Password:entered during setup



Add hosts to your Nagios Server

No you have Nagios up and running you should be able to see your current server stats, (if not click on “Services” on the left side of the Nagios dashboard), but what if you want to add more hosts. Well it’s a little complicated at first but once you get used to it you’ll be fine. First we need to edit some config files to tell Nagios to monitor a new host, below is a diagram of all the Nagios config files:


As we can see from this diagram every setting for Nagios is stored in a config file, most of these can be found in your /etc/nagios3/conf.d folder. To add some new hosts we need to add some lines to your /etc/nagios3/conf.d/localhost_nagios2.cfg file. First off we are only going to be adding new hosts, not services (see my NRPE tutorial if you want to monitor services aswell), so we only need add a small amount of code. The local host definition in your /etc/nagios3/conf.d/localhost_nagios2.cfg should look like this:

define host{
        use                     generic-host            ; Name of host template to use
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        }

Here we can see then the template is generic-host, the hostname and alias are set to localhost(127.0.0.1) and the address is set to 127.0.0.1. The use filed is important as if you enter a name here that doesn’t correspond to a template then Nagios will fail to start. The address field is also important, this is where you put the actual address for the server you want to monitor (either domain name or IP will work here). The host_name and alies fields are not as important and are only there to help the user distinguish between hosts. The difference between the two is host_name is read internally (so don’t use spaces or special characters) and alias is actually show to the user (you can use spaces and special characters).

So now it’s time to add your own host to your Nagios server, in this example we are going to add www.google.com as your new host, if you want you can subtitle your own attributes however I like to have Google as a host just to ensure my setup is correct. So start your favourite text editor and add the hollowing lines to the end of your /etc/nagios3/conf.d/localhost_nagios2.cfg

define host{
        use                     generic-host            ; Name of host template to use
        host_name               google
        alias                   Google
        address                 www.google.com
        }

to see the changes on your dashboard you need to restart Nagios, type:

sudo /etc/init.d/nagios3 restart

Now if you want to add your own hosts to your Nagios server repeat the last two steps substituting host_name, alias and address to your hosts details and restart Nagios to see the changes.

Please leave any comments or questions, thanks.

, , , , , , , , , ,

  1. No comments yet.

You must be logged in to post a comment.