
Nagios is an open-source tool for monitoring network applications, services, and other essential network devices. It detects faults through active monitoring and sends notification alerts when suspicious activity is detected. Similarly, it sends notifications when devices or services are back to their functional state.
It works on a Server/Agent architecture where the server that hosts Nagios (core) uses plugins to communicate with remote hosts through agents like the Nagios Remote Plugin Executor. The final reports generated from the logs are visually represented through the user interface.
This article explains how to install Nagios on Ubuntu 20.04 server.
Update the system packages.
Install all the required packages.
Download Nagios Core Setup files. To download the latest version, visit the official releases site.
Extract the downloaded files.
Navigate to the setup directory.
Run the Nagios Core configure script.
Compile the main program and CGIs.
Make and install group and user.
Add www-data directories user to the nagios group.
Install Nagios.
Initialize all the installation configuration scripts.
Install and configure permissions on the configs' directory.
Install sample config files.
Install apache files.
Enable apache rewrite mode.
Enable CGI config.
Restart the Apache service.
Create a user and set the password when prompted.
Download the Nagios Core plugin. To download the latest plugins, visit the plugins download page.
Extract the downloaded plugin.
Navigate to the plugins' directory.
Run the plugin configure script.
Compile Nagios Core plugins.
Install the plugins.
Verify the Nagios Core configuration.
Start the Nagios service.
Enable Nagios service to run at system startup.
Open your web browser and access Nagios web interface via the URL http://ServerIP/nagios. For example:
You have successfully installed Nagios Core on your server. To log in, use admin as your username and the password you set during the user account creation step as your password. You can now access the dashboard and begin configuring Nagios.
Now that your Nagios server is configured, it's time to configure a remote host to monitor.
To get started, connect as root over SSH to the host you want to monitor.
To monitor hosts, we need to add them to Nagios. By default, Nagios only monitors localhost (the server it's running on). We're going to add hosts that are part of our network to gain even more control. You will need to use the following instructions on all hosts that you want to monitor.
First, install nagios-plugins and nagios-nrpe-server:
Next, open the /etc/nagios/nrpe.cfg file. Replace the value of allowed_hosts with 127.0.0.1,0.0.0.0 replacing the second IP with the IP address of the Nagios server.
We will now open the file /etc/nagios/nrpe.cfg and replace a couple of values.
server_address to the private IP address of the host.allowed_hosts to the private IP address of your Nagios server.df -h /, copy the output, and put that as the value of command. It indicates your root file system.Save the file when you are finished.
Now restart NRPE:
Now that we've configured the host we're going to monitor, we need to switch back to our Nagios server and add the host to it. Open the following file with your favorite editor:
Use the following block as a template. Replace host with an appropriate name for your remote host, and update the host_name, alias, and address values accordingly.
This will allow you to simply monitor whether the server is up or down. Now reload Nagios:
Congratulations, you have completed a very basic Nagios setup for monitoring your servers. Now you can log into the Nagios web panel to view the status of your servers.
For more information on Nagios, please see the official documentation.
0 Comments
Be the first to comment and share your perspective with the community.