Documentation & Tutorials
This tutorial will explain how to configure a Nagios monitoring with an Apache web server to monitor your servers. It is an open source monitoring system which can automatically alert you in case of a server disfunction.
In this tutorial, we will install Nagios from its source to make sure that we have the latest version of the tool.
1 . Update the system and install the required packages:
2 . Create a user to run Nagios:
3 . Download the sources of Nagios, untar them and enter the directory:
4 . Before compiling the software, define the user and group to use:
5 . Compile the software:
6 . Once it has been compiled, run the following
make commands to install the application, init scripts and configuration files:
We will use Apache as Webserver for the Nagios interface. Nagios provides a sample configuration file, that we will use.
1 . Copy the configuration file to the Apache directory:
2 . Install the Nagios Plugins to have a set of tools to monitor your different services:
3 . Configure, compile and install them with the following commands:
Nagios and the required plugins are installed.
To monitor servers, we have to enable it in the file /usr/local/nagios/etc/nagios.cfg.
1 . Uncommment the line
cfg_dir=/usr/local/nagios/etc/servers and save the file.
2 . Create the folder to store configurations:
3 . Configure the contact email address in the file
1 . Start by enabling the required Apache modules:
2 . Create a nagiosadmin user for the web interface with the
3 . Enable the Apache vHost:
By default Nagios does not provide a systemd configuration file, so we have to create one by ourself.
This file contains the information where systemd can find the Nagios executable and configuration files and when to start it.
1 . Create the file:
2 . Put the following content in the file:
3 . Save the file and enable the service:
4 . Start the applications:
Your Nagios server is ready, and you can access the interface at
We use the nagiosadmin user and the password that you have created previously to log in.
5 . Once you are connected, click on Hosts on the left to see what Nagios is monitoring. By default it will only monitor the local host.
The NPRE service (Nagios Remote Plugin Executor) is an add-on that allows you to execute Nagios commands on a remote Linux servers. It is basically used to gather “local” information (like disk usage, RAM usage, CPU usage) of a remote machine. As these information are not broadcasted on the Internet, an agent has to run on the server which reports to the Nagios server.
These steps have to be done on the remote server.
1 . Install the software on the remote server:
2 . Download and unpack NRPE:
3 . Compile it with the following commands:
4 . Create users and groups:
5 . Install the configuration files:
6 . Install NRPE:
7 . Install the service, so NPRE can be managed by systemd:
8 . Edit the file /usr/local/nagios/etc/nrpe.cfg. Replace
IP_of_your_Nagios_Server with the IP address of your Nagios host:
9 . Restart the service:
10 . Download and install the Nagios plugins:
The following steps have to be done on the Nagios server
11 . On the Nagios server, create a configuration file in the directory /usr/local/nagios/etc/servers/ for each remote host that we want to monitor:
12 . Replace remote_host with the name of the remove server and put the following content in the file:
This file will monitor if the remote host replies on
ping, the disk usage of the host and if the
SSH service is up. You can find more configuration examples in the file /usr/local/nagios/etc/objects/commands.cfg. Nagios allows you to monitor a wide range of services.
13 . Save the file and restart the application:
The remote server will appear in your Nagios interface and you can see the status of the monitored services:
Nagios is widely used because of its flexibility and versatility. Don’t hesitate to refer to the Documentation of the software to find more out about further configuration options.