Install Nagios 4 on Ubuntu and Debian 8
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
DeprecatedThis guide has been deprecated and is no longer being maintained.
A monitoring tool is a key application in a production server. Nagios is a popular tool that provides monitoring and alerting services for your servers, applications and services. Using Nagios and a wide variety of available plugins, you can keep track of the status of your critical services like HTTP, SSH and SMTP. In this guide, you’ll learn how to install Nagios 4 on your Linode.
Before You Begin
In order to run Nagios on your Linode, follow the configuration steps for Ubuntu or Debian 8 from our Setting Up and Securing a Compute Instance.
Install and configure a LAMP stack (Linux, Apache, MySQL and PHP stack). Follow the LAMP on Ubuntu 14.04 or LAMP on Debian 8 guide for instructions.
Install updates:
sudo apt-get update && sudo apt-get upgrade
sudo
. If you’re not familiar with the sudo
command, you can check our
Users and Groups guide.Install Nagios
Create Users and Groups
Create a user, nagios
, and a distinct group, nagcmd
. Add nagios
and the Apache user, www-data
, to the nagcmd
group in order to run external commands on Nagios through the web interface:
sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios && sudo usermod -a -G nagcmd www-data
Build Nagios 4 from Source Code
The latest stable version of Nagios 4 is not available in Ubuntu or Debian’s default repositories as of this writing. To install Nagios, download and install it from the source code:
Install dependencies:
sudo apt-get install build-essential unzip openssl libssl-dev libgd2-xpm-dev xinetd apache2-utils
In your web browser, go to the Nagios Core DIY download page. If you prefer not to register for updates, click Skip to download.
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.
Download and extract Nagios to your Linode using
wget
andtar
, pasting the link from Step 3:wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz tar -xvf nagios-4.*.tar.gz
Move to the newly created directory:
cd nagios-4.*
Configure, compile and install Nagios:
./configure --with-nagios-group=nagios --with-command-group=nagcmd make all sudo make install sudo make install-init sudo make install-config sudo make install-commandmode
Prepare Apache and Configure Nagios Web Interface
Make sure Apache has
mod_rewrite
andmod_cgi
enabled:sudo a2enmod rewrite && sudo a2enmod cgi
Copy the sample virtual host configuration Nagios provides to
sites-available
:sudo cp sample-config/httpd.conf /etc/apache2/sites-available/nagios4.conf
Restrict
nagios4.conf
file permissions:sudo chmod 644 /etc/apache2/sites-available/nagios4.conf
Enable the new virtual host:
sudo a2ensite nagios4.conf
The web interface requires login. Create a
nagiosadmin
account and record the password you assign:sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache
sudo service apache2 restart
Install Nagios Plugins
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP. To use Nagios Plugins, go to the Nagios Plugins downloads page and copy the download link for the current stable release (e.g., http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
):
Download and extract Nagios Plugins to your Linode using
wget
andtar
, pasting the link you copied:wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz tar -xvf nagios-plugins-2*.tar.gz
Change to the newly created directory, then configure, compile, and install Plugins:
cd nagios-plugins-2.* ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl make sudo make install
Access the Nagios Web Interface
Before accessing the Nagios Web Interface, start the Nagios service:
sudo service nagios start
Note For Ubuntu versions after 14.04, see the Systemd section below before running this step.The interface can be accessed in your web browser by appending
/nagios
to your domain or Public IP. When prompted at login, usenagiosadmin
as the user and use the password you assigned in the Configure Nagios Web Interface section.You will be greeted with a screen like this one:
To view monitoring status, click the Hosts link in the menu on the left. This example screenshot shows an active Nagios server called
localhost
:
Systemd
As of this guide’s publication, the Nagios build process does not create a systemd service file. In order to manage the service with systemd, create a Nagios service file for the system to load on initialization:
- File: /etc/systemd/system/nagios.service
1 2 3 4 5 6 7 8 9 10 11 12
[Unit] Description=Nagios BindTo=network.target [Install] WantedBy=multi-user.target [Service] User=nagios Group=nagios Type=simple ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
Enable the link, start the Nagios service, and check the status:
sudo systemctl enable /etc/systemd/system/nagios.service
sudo systemctl start nagios
systemctl status nagios
You can now continue at Access the Nagios Web Interface
Next Steps
Nagios contains numerous features that are beyond the scope of this document. Explore the Nagios administrative interface as well as the resources listed below to access more information regarding the setup and configuration of Nagios.
Congratulations on your new Nagios monitoring and notification system!
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on