Install Nagios on Linux Mint 18 / Linux Mint 17

2

Nagios is the most widely used open source monitoring tools which help us to monitor the services and application that run’s on Windows, Linux, Routers and other network devices. With the help of Nagios, you can monitor basic services and attributes.

We can access the Nagios using web interface coming with the bundle and configurations need to be done on the file level.

Whats New

  • Core Workers are a lightweight process whose job is to perform checks, due to this they do perform checks much more quickly than the old process.
  • Nagios Core process using in-memory techniques, eliminating the disk I/O latencies that could previously slow things down in a large installation.
  • Each configuration item is verified only once.
  • The host address attribute is now optional.
  • Both hosts and services now support an hourly value attribute.

More feature can be found here.

Services List

This Tutorial describes how 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

Switch to the root user.

sudo su -

Install the dependencies for Nagios 4.

apt-get update
apt-get 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

Create nagios user and nagcmd group (allowing the external commands to be executed through the web interface), add the nagios and apache user to the part of the nagcmd group.

useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www-data

Download the latest version of Nagios Core.

cd /tmp/
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.7.tar.gz
tar -zxvf /tmp/nagios-4.3.4.tar.gz
cd /tmp/nagios-4.3.4/

Compile and Install Nagios:

./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

Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You’ll need to make just one change before you proceed…

Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts.

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

Change the Email address field 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                           admin@itzgeek.com       ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }

Configure Web Interface

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

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

Run the following command.

a2enmod cgi

Restart Apache to make the new settings take effect.

service apache2 restart

Download and Install Nagios Plugins

Download Nagios Plugins to /tmp directory.

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

Verify the sample Nagios configuration files.

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

In Linuxmint 18, you need to use systemd for starting/stopping all the services. So, we need to create nagios.service file.

nano /etc/systemd/system/nagios.service

Add the below content to above file.

[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 Nagios to start automatically at system startup.

systemctl enable /etc/systemd/system/nagios.service

Now, start the Nagios service.

service nagios start

Access Nagios Web Interface

Now access the Nagios web interface using the following URL.

http://ip-address/nagios/

You’ll be prompted for the username (nagiosadmin) and password you specified earlier.

Install Nagios on Linux Mint 18 - Access Password
Install Nagios on Linux Mint 18 – Access Password

Nagios Dashboard:

Install Nagios on Linux Mint 18 - Nagios DashBoard
Install Nagios on Linux Mint 18 – Nagios DashBoard

Monitoring Services:

Install Nagios on Linux Mint 18 - Service Monitoring Page
Install Nagios on Linux Mint 18 – Service Monitoring Page

That’s All. Now, you are ready to add Linux machines to Nagios Monitoting tool.

You might also like

Install Nagios on Linux Mint 18 / Linux Mint 17

2