Nagios 3 on Debian Wheezy or Ubuntu 14.x

After a quick dap with Observium, I’ve decided to go back to Nagios. Nagios3 is a full featured monitoring package for Linux hosts.
The article will describe how to install Nagios 3 on a Debian or Ubuntu host. For the people who never heard about Nagios, please take a look at http://www.nagios.org/projects/nagioscore . In this how-to we will use the opensource version, named Nagios Core.

To start with Nagios Core, you will need a fully functioning LAMP server. If you don’t have a LAMP enviroment run the following command:

The MySQL install will ask you for an administrative password who you will need to enter 2 times.

After the LAMP installation we can go further with the Nagios installation. Run the following command on your Nagios server:

I gave the password as per my choice, please give the values as per your server environment.

Next we need to configure the Nagios at Server, as follows:

Next change the values for check_external_commands to 1 to enable settings as follows:

Now we need to make the changes effective by restarting the Nagios service by using the command:

Accessing the web-interface at http://server1.example.com/nagios3 or http://IP/nagios3 as follows:

Username will be nagiosadmin and password as created above!

Next click on Host Groups:

It will show the present server as localhost. Just click over the localhost.

Now that the basic setup of the Nagios server is finished, we can add our first client / server to monitor.

A monitored client/server on Nagios is called a “host”. To add a host you will need to install the following package:

Further at  server2.example.com define the main Nagios monitoring server entries in Nagios configuration file as :

Where 192.168.0.100 is the main Nagios monitor server server1.example.com IP. Next start nrpe service as shown below

Similarly we can add more nodes to which we want monitoring.

We also need to define the Nagios client entries at server end. Create a file monitor1.cfg in directory /etc/nagios3/conf.d/ and define the values at server1.example.com. In the object configuration files, you can define hosts, host groups, contacts, contact groups, services, etc. You can split your object definitions across several config files if you wish, or keep them all in a single config file.

Default directory is /etc/nagios3/conf.d/ , you can use any name such as I used monitor1.cfg Entries must be like this:

In above file define host contains the information about the added client server2.example.com, next we can use Nagios to check different services. I used to check PING SSH and DISK services. For more details of services used in Nagios check directory /etc/nagios-plugins/config.

Next to make the changes effective restart the nagios3 service.

Now we can check the client details at the Nagios web-interface at Host Groups as follows:

Next on server2.example.com and check the values there.

 

That is it! Now you have a working Nagios server with 2 monitored hosts.

In following posts I will describe how you can implement monitoring alerts, have detailed graphs and much more. So stay tuned!