Nagios Installation overview

 

Nagios Installation Ubuntu 16.04


 

Prerequisites

2 Ubuntu 16.04 - 64bit servers

1 - Nagios Host with IP: 192.168.1.9

2 - Ubuntu Client with IP: 192.168.1.10

Root/Sudo access

 

1.       sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip

2.       User and Group Config

useradd nagios

groupadd nagcmd

usermod -a -G nagcmd nagios

usermod -a -G nagios,nagcmd www-data

3.       Nagios Installation

a.       cd ~
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz
tar -xzf nagios*.tar.gz
cd nagios-4.2.0

4.       ./configure --with-nagios-group=nagios --with-command-group=nagcmd

make all
sudo make install
sudo make install-commandmode
sudo make install-init
sudo make install-config
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf

cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

 

5.       Plugins installation

a.       cd ~
wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz
tar -xzf nagios-plugins*.tar.gz
cd nagios-plugin-2.1.2/

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

c.       vi /usr/local/nagios/etc/nagios.cfg

uncomment line 51 for the host monitor configuration.

cfg_dir=/usr/local/nagios/etc/servers

 

6.       mkdir -p /usr/local/nagios/etc/servers

7.       The Nagios contact can be configured in the contact.cfg file. To open it use:

a.       Vi /usr/local/nagios/etc/objects/contacts.cfg

 

 

Apache Config:

1. sudo a2enmod rewrite
sudo a2enmod cgi

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

3. sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/

Restart Apache service

 

 

Nagios Config:

1.       vi /etc/init.d/Nagios

a.       Add below

DESC="Nagios"

NAME=nagios

DAEMON=/usr/local/nagios/bin/$NAME

DAEMON_ARGS="-d /usr/local/nagios/etc/nagios.cfg"

PIDFILE=/usr/local/nagios/var/$NAME.lock

2.       chmod +x /etc/init.d/nagios
service apache2 restart
servuce nagios start

3.       Login in Browser with Nagios IP

 

 

Adding Host to Monitor

1.       Connect to Ubuntu host  and Install NRPE

a.       sudo apt-get install nagios-nrpe-server nagios-plugins

2.       Configure NRPE

a.       vi /etc/nagios/nrpe.cfg

                                                               i.      server_address= <Enter your server IP>

3.       Restart NRPE

a.       service nagios-nrpe-server restart

4.       Add Ubuntu Host to Nagios Server

a.       vi /usr/local/nagios/etc/servers/ubuntu_host.cfg

# Ubuntu Host configuration file

define host {

        use  linux-server

        host_name                    ubuntu_host

        alias                        Ubuntu Host

        address                      192.168.1.10

        register                     1

}

 

define service {

      host_name                       ubuntu_host

      service_description             PING

      check_command                   check_ping!100.0,20%!500.0,60%

      max_check_attempts              2

      check_interval                  2

      retry_interval                  2

      check_period                    24x7

      check_freshness                 1

      contact_groups                  admins

      notification_interval           2

      notification_period             24x7

      notifications_enabled           1

      register                        1

}

 

define service {

      host_name                       ubuntu_host

      service_description             Check Users

      check_command           check_local_users!20!50

      max_check_attempts              2

      check_interval                  2

      retry_interval                  2

      check_period                    24x7

      check_freshness                 1

      contact_groups                  admins

      notification_interval           2

      notification_period             24x7

      notifications_enabled           1

      register                        1

}

 

define service {

      host_name                       ubuntu_host

      service_description             Local Disk

      check_command                   check_local_disk!20%!10%!/

      max_check_attempts              2

      check_interval                  2

      retry_interval                  2

      check_period                    24x7

      check_freshness                 1

      contact_groups                  admins

      notification_interval           2

      notification_period             24x7

      notifications_enabled           1

      register                        1

}

 

define service {

      host_name                       ubuntu_host

      service_description             Check SSH

      check_command                   check_ssh

      max_check_attempts              2

      check_interval                  2

      retry_interval                  2

      check_period                    24x7

      check_freshness                 1

      contact_groups                  admins

      notification_interval           2

      notification_period             24x7

      notifications_enabled           1

      register                        1

}

 

define service {

      host_name                       ubuntu_host

      service_description             Total Process

      check_command                   check_local_procs!250!400!RSZDT

      max_check_attempts              2

      check_interval                  2

      retry_interval                  2

      check_period                    24x7

      check_freshness                 1

      contact_groups                  admins

      notification_interval           2

      notification_period             24x7

      notifications_enabled           1

      register                        1

}

 

 

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

6.       Restart services

a.       service nagios-nrpe-server restart

b.       service apache2 restart
service nagios restart

Comments

Popular posts from this blog

300 +DevOps Interview Questions and Answers

Kubernetes installation step-by-step in various OS