Install Nagios in Ubuntu

Nagios is one of the most common tools monitoring servers Linux and Windows open source. With it, you will be able to monitor the implementation of various applications and services remotely via a web interface. Nagios can also monitor the routers and other network devices.

With Nagios you can monitor basic server parameters such as CPU load, memory usage, etc etc Everything is available in the web interface, for access to which you need to pass simple authentication. In this article we will discuss how to install Nagios Ubuntu and configure this program.

Install Nagios in Ubuntu

There are several ways to install Nagios Ubuntu 16.04. You can use the PPA or install using the files uploaded on the official website. At the moment the latest version is 4.3. PPA is only available in 4.2, so we will consider manual installation using the files.

But before we move on to the installation, you must update the system and install all the necessary components for the build:

 sudo apt update

 sudo apt install build-essential apache2 php7.0 make openssl perl php7.0-gd libgd2-xpm-dev libapache2-mod-php7.0 libperl-dev libssl-dev daemon wget apache2-utils unzip

Then you need to create a group and user on behalf of which will run Nagios, and shell commands executed in the web interface:

 sudo useradd nagios
$ sudo groupadd nagcmd

Add the user nagios and the user name that Apache runs in group nagcmd:

 sudo usermod -a-G nagcmd nagios
$ sudo usermod -a-G nagcmd www-data

Then we need to download source code of nagios. This can be done using terminal commands, but because we want to get the newest version, it is better to go to the official website and download.

First click on “Nagios Core”, then scroll down and hit “Download”:

At this stage you can fill in information about yourself, or skip by clicking “Skip download”:

It remains to choose version, for example, 4.3.2. After the download is complete go to the folder with the downloads and extract the archive:

 cd ~/Downloads/
$ tar -zxvf /tmp/nagios-4.3.2.tar.gz

You can now proceed to compile nagios. To do this, execute the following commands:

 ./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd_conf=/etc/apache2/sites-enabled/
$ make all
$ sudo make install
$ sudo make install-init
$ sudo make install-config
$ sudo make install-commandmode
$ sudo make install-webconf

Setup Nagios in Ubuntu

All configuration files of the program will be placed by the installer in /usr/local/nagios/etc/. The default settings allow you to run Nagios, but we need to make a few more changes. Open the contact file.cfg and change the email address that will receive alerts:

 sudo vi /usr/local/nagios/etc/objects/contacts.cfg

define contact{
message contact_name nagiosadmin ; Short name of user
use generic-contact ; the default Template
alias Nagios Admin ; Full name of user
email [email protected] Your Email
}

To operate the web interface, you must create a password for the user nagiosadmin with the help of htpasswd, without it you simply will not be able to enter the interface:

 sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Finally, to work correctly you need to make a few tweaks to the web server. Enable the cgi module:

 sudo a2enmod cgi

Restart the web server:

 sudo service apache2 restart

For more options nagios you can install a set of plugins. To do this, first download it:

Now unzip the archive and navigate to the folder:

 tar-zxvf /tmp/nagios-plugins-2.1.1.tar.gz
$ cd /tmp/nagios-plugins-2.1.1/

To compile the modules, run:

 ./configure --with-nagios-user=nagios --with-nagios-group=nagios
$ make
$ make install

Modules installed in a directory with Nagios, now verify the configuration:

 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

To start automatically, create a Unit file for systemd:

 sudo vi /etc/systemd/system/nagios.service

[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

Start Nagios

Everything is almost ready, it remains to run the service and start to use. To start the service, type:

 sudo systemctl stat nagios

To open the nagios web interface will be sufficient to type the ip address and the url of nagios in the browser. If you installed all of this on the local computer, use:

http://localhost/nagios

Immediately after opening the page you will need to enter the username nagiosadmin and the password you gave it earlier. Then you can use all the features of the program:

Insights

In this article, we considered how do you configure nagios 4 as well as full installation of the latest version in the Ubuntu operating system. Despite the fact that, at first glance, it all looks complicated, the process is fairly simple. You can now monitor the nagios ubuntu 16.04. I hope this information was useful for you.

Source: losst.ru

(Visited 29 times, 1 visits today)