Linux, Windows, Virtualization, OpenSource & Blogging

How to Install Nagios 4.3.2 on Debian 9 Stretch

0
Install Nagios 4.3.2 on Debian 9 Stretch
Install Nagios 4.3.2 on Debian 9 Stretch

Nagios is an open source monitoring tool for servers, network devices, and applications. It helps you to monitor the services, resources, and applications that run’s on Windows as well as on Linux. Nagios also can monitor routers and other network devices.

Nagios has an inbuilt web interface where we can access and monitor the whole infrastructure at a single location. You have to work on the file level (configuration file) as you can not customize or adjust the monitoring parameters over the web interface.

Services List

With the Nagios, you can monitor “private” services and “attributes” of Linux/UNIX servers, such as:

Attributes

  • CPU load
  • Memory usage
  • Disk usage
  • Logged in users
  • Running processes
  • etc.

Private Services

  • HTTP
  • FTP
  • SSH
  • SMTP
  • etc

Install Nagios 4.3.2 on Debian 9

Prerequisites

Nagios 4.3.2 is the latest version at the time of writing, before compiling Nagios from the source; install dependent packages for Nagios monitoring tool.

Visit the official website for downloading the latest version Nagios Core.

Let’s switch to root user.

su -

OR

sudo su -

Update the repository cache index and install the dependencies for Nagios.

apt-get update 
apt-get -y install build-essential apache2 php openssl perl make php-gd libgd2-xpm-dev libapache2-mod-php libperl-dev libssl-dev daemon wget apache2-utils unzip

Create a user for allowing the external commands to be executed through the web interface.

user: nagios

group: nagcmd

Also, add “nagios” and apache user (www-data) to the part of “nagcmd” group.

useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www-data
cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.2.tar.gz
tar -zxvf nagios-4.3.2.tar.gz
cd /tmp/nagios-4.3.2/

Use below steps to compile Nagios from the source code.

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

Configure Nagios

The installer has now placed configuration files in the “/usr/local/nagios/etc” directory. You don’t need to modify Nagios configuration files for now to start Nagios monitoring tool.

All you need is to update email address in the “/usr/local/nagios/etc/objects/contacts.cfg” file for “nagiosadmin” before you start Nagios…

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

Change to the email address of your choice to receive the notification.

define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user

        email                           nagios@itzgeek.com      ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }

Configure Nagios Web Interface

Create a user “nagiosadmin” account for logging into the Nagios web interface. Remember the password you assign to user “nagiosadmin” – you’ll need it later.

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

To enable CGI, run:

a2enmod cgi

Restart Apache web service to make the new settings take effect.

service apache2 restart

Download and Install Nagios Plugins

Now, it’s time to download and install Nagios plugins for monitoring the services.

cd /tmp
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
tar -zxvf /tmp/nagios-plugins-2.2.1.tar.gz
cd /tmp/nagios-plugins-2.2.1/

Compile and install the plugins.

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

Start Nagios Server

Verify the sample Nagios configuration files.

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

Start Nagios monitoring tool using the following command.

/etc/init.d/nagios start

Enable Nagios to start automatically at the system startup.

systemctl enable nagios

Firewall

Configure the firewall so that the Nagios Web Interface can be accessible from external machines.

FirewallD:

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload
systemctl restart firewalld

UFW:

ufw allow 80/tcp
ufw reload
ufw enable

Access Nagios Web Interface

Now, go and access the Nagios web interface using the below URL. The browser will prompt you to enter the username “nagiosadmin” and the password you specified earlier.

http://ip-address/nagios/
Install Nagios 4.3.2 on Debian 9 Stretch - Services
Install Nagios 4.3.2 on Debian 9 Stretch – Services

By default, Nagios can monitor only localhost, ie, Nagios server. If you want to monitor remote machines, you need to install and configure NRPE plugin.

READ: How To Add Linux Host To Nagios Monitoring Using NRPE Plugin

Interested in Other Server Monitoring Tools

READ: How To Install Zabbix Server 3.2 on CentOS 7 / Ubuntu 16.04 / Debian 8

READ: Install Icinga2 on Ubuntu 16.04 / 14.04, Debian, and Mint

READ: Install Monitorix on CentOS 7 / Ubuntu 16.04 / Fedora 24 / Debian 8 – OpenSource Lightweight System Monitoring Tool

READ: Netdata – Real-Time Performance Monitoring Tool for Linux

That’s All. Hope this post helped you. Post your valuable comments below.

POSTS YOU MAY LIKE -:)

You might also like

How to Install Nagios 4.3.2 on Debian 9 Stretch

0