Installing Nagios on Ubuntu |  Losst
0

Nagios is one of the most widely used open source Linux and Windows server monitoring tools. With it, you can monitor the execution of various applications and services remotely through the web interface. Nagios can also monitor routers and other network devices.

With Nagios, you can monitor basic server parameters such as CPU load, memory usage, and so on. All of this is available in the web interface, which requires simple authentication to be accessed. In this article, we will look at how to install Nagios Ubuntu, as well as how to configure this program.

The content of the article:

Installing Nagios on Ubuntu

There are several ways to install Nagios Ubuntu 16.04. You can use the PPA or install using the archive downloaded from the official site. At the moment, the most recent version is 4.3. There is only 4.2 available in the PPA, so we will cover manual installation using an archive.

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

sudo apt update

sudo apt install build-essential apache2 php7.0 openssl perl make 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 a user on behalf of which Nagios will run, as well as shell commands executed in the web interface:

sudo useradd nagios
$ sudo groupadd nagcmd

Add the nagios user and the user under which Apache runs to the nagcmd group:

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

Installing Nagios on Ubuntu | Webilicious 3

Then we need to download the nagios source codes. This can be done using the terminal command, but since we want to get the latest version, it is better to go to official site and download.

Installing Nagios on Ubuntu | Webilicious 4

First click on the item “Nagios Core”, then scroll down and press “Download”:

Installing Nagios on Ubuntu | Webilicious 5

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

Installing Nagios on Ubuntu | Webilicious 6

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

cd ~/Загрузки/
$ tar -zxvf /tmp/nagios-4.3.2.tar.gz

Installing Nagios on Ubuntu | Webilicious 7

Now you can proceed to compiling nagios. To do this, you need to run 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

Installing Nagios on Ubuntu | Webilicious 8

Installing Nagios on Ubuntu | Webilicious 9

Setting up Nagios on Ubuntu

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

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

define contact{
contact_name nagiosadmin ; Краткое имя пользователя
use generic-contact ; Шаблон по умолчанию
alias Nagios Admin ; Полное имя пользователя
email [email protected] ; Ваш Email
}

Installing Nagios on Ubuntu | Webilicious 10

For the web interface to work, you need to create a password for the nagiosadmin user using htpasswd, without it you simply cannot enter the interface:

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

Installing Nagios on Ubuntu | Webilicious 11

Finally, for this to work, you need to make a few settings for the web server. Include the cgi module:

sudo a2enmod cgi

Restart the web server:

sudo service apache2 restart

Installing Nagios on Ubuntu | Webilicious 12

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

Installing Nagios on Ubuntu | Webilicious 13 Installing Nagios on Ubuntu | Webilicious 14

Now unzip the archive and go to the folder with it:

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

Installing Nagios on Ubuntu | Webilicious 15

To compile modules run:

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

The modules are installed in the folder with Nagios, now check if the configuration is correct:

/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

Installing Nagios on Ubuntu | Webilicious 16

Launch Nagios

Almost everything is ready, all that remains is to start the service and start using it. To start the service, type:

sudo systemctl stat nagios

Installing Nagios on Ubuntu | Webilicious 17

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

http://localhost/nagios

Installing Nagios on Ubuntu | Webilicious 18

Immediately after opening the page, you will need to enter the username nagiosadmin and the password that you set for it earlier. After that, you can use all the features of the program:

Installing Nagios on Ubuntu | Webilicious 19

conclusions

In this article, we looked at how to configure nagios 4, as well as complete installation of the latest version on the Ubuntu operating system. Despite the fact that, at first glance, everything seems complicated, the process is quite simple. You can now monitor nagios ubuntu 16.04. Hope this information was helpful to you.

Redirect from http to https Nginx

Previous article

Installing OpenMediaVault on a USB flash drive | Webilicious

Next article

You may also like

Comments

Leave a Reply

More in Linux