How to Install nagios for cloudera or hadoop or hortonworks and monitor all cloudera or hadoop or hortonworks hosts using nagios

you must have superuser privileges on the CentOS 7 server that will run Nagios. A LAMP stack is also required.

cloudera-nagios-1

Step 1: Install LAMP

Run below commands:

               
yum update -y
sudo yum install httpd
sudo service httpd start
ifconfig eth0 | grep inet | awk '{ print $2 }'
                
               

Install Mysql Server:

               
yum install wget -y
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
md5sum mysql57-community-release-el7-9.noarch.rpm
sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm                
  
      

Grep Temporary Password:


sudo grep 'temporary password' /var/log/mysqld.log              

Mysql Server Secure Installation:

               

sudo /usr/bin/mysql_secure_installation


Enter current password for root (enter for none): 
OK, successfully used password, moving on...
  
      
   

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y                                            
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!
  
      

Run Below Commands:


sudo yum install php php-mysql
sudo service mysqld start

sudo chkconfig httpd on
sudo chkconfig mysqld on            

To set this up, first create a new file:

sudo vi /var/www/html/info.php

Add in the following line:

           

<?php 
phpinfo();

?>

Then Save and Exit.

Run Below Commands:


sudo service httpd restart           

nagios-lamp-cloudera

Install Nagios:


sudo yum install gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel xinetd unzip

Create Nagios User and Group:


sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios

Install Nagios Core:


cd ~
curl -L -O https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz

Extract the Nagios archive with this command:


tar xvf nagios-*.tar.gz
cd nagios-*
./configure --with-command-group=nagcmd 

Compile Nagios:


make all
sudo make install
sudo make install-commandmode
sudo make install-init
sudo make install-config
sudo make install-webconf

We must add the web server user, apache, to the nagcmd group:


sudo usermod -G nagcmd apache

cd ~
curl -L -O http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
tar xvf nagios-plugins-*.tar.gz
cd nagios-plugins-*
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl

Now compile Nagios Plugins with this command:


make
sudo make install

cd ~
curl -L -O http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

tar xvf nrpe-*.tar.gz
cd nrpe-*
./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu

Now build and install NRPE and its xinetd startup script with these commands:


make all
sudo make install
sudo make install-xinetd
sudo make install-daemon-config


Open the xinetd startup script in an editor:


sudo vi /etc/xinetd.d/nrpe


Modify the only_from line by adding the private IP address of the your Nagios server

cloudera nagios server setup 1

only_from = 127.0.0.1 10.128.0.2


Save and exit. and restart xinetd service


:wq
sudo service xinetd restart

Configure Nagios into cloudera and hadoop hortonworks server

nagios-server-dir

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

Now find an uncomment this line by deleting the #:

#cfg_dir=/usr/local/nagios/etc/servers
Save and exit.

:wq

Now create the directory that will store the configuration file for each cloudera or hadoop or hortonworks server that you will monitor:


sudo mkdir /usr/local/nagios/etc/servers

Configure Email for cloudera or hadoop or hortonworks servers alerts


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


email                           youremailid@company.com        ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
Save and exit.

:wq

Configure check_nrpe Command

nagios-nrp-cloudera

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

Add the following to the end of the file:

define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

Save and exit.

:wq

Configure Apache - Use htpasswd to create an admin user, called "nagiosadmin", that can access the Nagios web interface:

nagios-web-ui-username-password-cloudera

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

Enter a password at the prompt. Remember this login, as you will need it to access the Nagios web interface.

Run below commands


sudo systemctl daemon-reload
sudo systemctl start nagios.service
sudo systemctl restart httpd.service
sudo chkconfig nagios on

Nagios Running into cloudera or hadoop or hortonworks server, so let's try and log in.


http://nagios_server_public_ip/nagios

nagios-home-page

Nagios host tab.

nagios-host-tab-cloudera