Showing posts with label Nagios. Show all posts
Showing posts with label Nagios. Show all posts

How to install NRPE plugin for nagios on Ubuntu

By // No comments:

How to install NRPE plugin on Ubuntu

In this article we will learn that how to install NRPE plugin in nagios. NRPE (Nagios Remote Plugin Executor) is used for executing Nagios plugins on remote client systems.

We have simple steps to install NRPE plugin in ubuntu. please let us know if you have any doubt and query by comments and mail.
 

Make sure that you have the following packages installed.

sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget



Downloading the Source

cd /tmp
wget --no-check-certificate -O nrpe.tar.gz https://github.com/NagiosEnterprises/nrpe/archive/nrpe-3.2.1.tar.gz
tar xzf nrpe.tar.gz



Compile
Note that if you want to pass arguments through NRPE you must specify this in the configuration option as indicated below. If you prefer to you can omit the --enable-command-args flag. Removing this flag will require that all arguments be explicitly set in the nrpe.cfg file on each server monitored.

===== i386 =====

cd /tmp/nrpe-nrpe-3.2.1/
sudo ./configure --enable-command-args --with-ssl-lib=/usr/lib/i386-linux-gnu/
sudo make all



===== x86_x64 =====

cd /tmp/nrpe-nrpe-3.2.1/
sudo ./configure --enable-command-args --with-ssl-lib=/usr/lib/x86_64-linux-gnu/
sudo make all



Create User And Group:- This creates the nagios user and group.

sudo make install-groups-users
 


Install Binaries:-

This step installs the binary files, the NRPE daemon and the check_nrpe plugin.

If you only wanted to install the daemon, run the command make install-daemon instead of the command below. However it is useful having the check_nrpe plugin installed for testing purposes.

If you only wanted to install the check_nrpe plugin, refer to the section at the bottom of this KB article as there a lot of steps that can be skipped. Installing only the plugin is usually done on your Nagios server and workers.



sudo make install


Install Configuration Files, This installs the config files.

sudo make install-config


Update Services File
The /etc/services file is used by applications to translate human readable service names into port numbers when connecting to a machine across a network.

sudo sh -c "echo >> /etc/services"
sudo sh -c "sudo echo '# Nagios services' >> /etc/services"
sudo sh -c "sudo echo 'nrpe    5666/tcp' >> /etc/services"



Install Service / Daemon
This installs the service or daemon files.

===== 13.x / 14.x =====

sudo make install-init


===== 15.x / 16.x / 17.x =====

sudo make install-init
sudo systemctl enable nrpe.service


Information on starting and stopping services will be explained further on.

Configure Firewall

Port 5666 is used by NRPE and needs to be opened on the local firewall.

sudo mkdir -p /etc/ufw/applications.d
sudo sh -c "echo '[NRPE]' > /etc/ufw/applications.d/nagios"
sudo sh -c "echo 'title=Nagios Remote Plugin Executor' >> /etc/ufw/applications.d/nagios"
sudo sh -c "echo 'description=Allows remote execution of Nagios plugins' >> /etc/ufw/applications.d/nagios"
sudo sh -c "echo 'ports=5666/tcp' >> /etc/ufw/applications.d/nagios"
sudo ufw allow NRPE

sudo ufw allow 5666
 sudo ufw reload
 


Update Configuration File
The file nrpe.cfg is where the following settings will be defined. It is located:

/usr/local/nagios/etc/nrpe.cfg



allowed_hosts=

At this point NRPE will only listen to requests from itself (127.0.0.1). If you wanted your nagios server to be able to connect, add it's IP address after a comma (in this example it's 192.168.0.142):

allowed_hosts=127.0.0.1,192.168.0.142


dont_blame_nrpe=

This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed. We are going to allow this, as it enables more advanced NPRE configurations.

dont_blame_nrpe=1


The following commands make the configuration changes described above.

sudo sh -c "sed -i '/^allowed_hosts=/s/$/,192.168.0.142/' /usr/local/nagios/etc/nrpe.cfg"
sudo sh -c "sed -i 's/^dont_blame_nrpe=.*/dont_blame_nrpe=1/g' /usr/local/nagios/etc/nrpe.cfg"



Start Service / Daemon:- Different Linux distributions have different methods of starting NRPE.

===== 13.x / 14.x =====

sudo start nrpe


===== 15.x / 16.x / 17.x =====

sudo systemctl start nrpe.service


Test NRPE

Now check that NRPE is listening and responding to requests.

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1

 You should see the output similar to the following:

NRPE v3.2.1
If you get the NRPE version number (as shown above), NRPE is installed and configured correctly.

You can also test from your Nagios host by executing the same command above, but instead of 127.0.0.1 you will need to replace that with the IP Address / DNS name of the machine with NRPE running.



Service / Daemon Commands
Different Linux distributions have different methods of starting / stopping / restarting / status NRPE.

===== 13.x / 14.x =====

sudo start nrpe
sudo stop nrpe
sudo restart nrpe
sudo status nrpe



===== 15.x / 16.x / 17.x =====

sudo systemctl start nrpe.service
sudo systemctl stop nrpe.service
sudo systemctl restart nrpe.service
sudo systemctl status nrpe.service



Installing The Nagios Plugins
NRPE needs plugins to operate properly. The following steps will walk you through installing Nagios Plugins.

These steps install nagios-plugins 2.2.1. Newer versions will become available in the future and you can use those in the following installation steps. Please see the releases page on GitHub for all available versions.

Please note that the following steps install most of the plugins that come in the Nagios Plugins package. However there are some plugins that require other libraries which are not included in those instructions. Please refer to the following KB article for detailed installation instructions:

Documentation - Installing Nagios Plugins From Source

Prerequisites :- Make sure that you have the following packages installed.

sudo apt-get install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext


Downloading the Source

cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar zxf nagios-plugins.tar.gz



To Compile and Install nagios plugin

cd /tmp/nagios-plugins-release-2.2.1/
sudo ./tools/setup
sudo ./configure
sudo make
sudo make install



Test NRPE + Plugins
Now you can check that NRPE is executing plugins correctly. The default configuration file /usr/local/nagios/etc/nrpe.cfg has the following command defined in it:

command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20


Using the check_load command to test NRPE:

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_load


You should see the output similar to the following:

OK - load average: 0.01, 0.13, 0.12|load1=0.010;15.000;30.000;0; load5=0.130;10.000;25.000;0; load15=0.120;5.000;20.000;0;


You can also test from your Nagios host by executing the same command above, but instead of 127.0.0.1 you will need to replace that with the IP Address / DNS name of the machine with NRPE running.

How to install and configure nagios on Ubuntu

By // No comments:

How to install and configure nagios core on Ubuntu:

Today we will see in this articles that how to install open source monitoring tool nogios core on Ubuntu.  It's more important tool which help us to identify that our ISP connection is up and not even we can add also server, computer and printer. Please follow all below step to install nagios core from open source.



Perform these steps to install nagios core from open source:-

===== Ubuntu 14.x / 15.x =====


sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 apache2-utils php5 libgd2-xpm-dev


===== Ubuntu 16.x / 17.x =====

sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.0 libgd2-xpm-dev


===== Ubuntu 18.x =====

sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.2 libgd-dev


To Download the Source

cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.1.tar.gz
tar xzf nagioscore.tar.gz


Compile
cd /tmp/nagioscore-nagios-4.4.1/
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all


Create User And Group

This creates the nagios user and group. The nagiosusr user is also added to the nagios group.

sudo make install-groups-users
sudo usermod -a -G nagios nagiosusr




Install Binaries
This step installs the binary files, CGIs, and HTML files.


sudo make install


Install Service / Daemon
This installs the service or daemon files and also configures them to start on boot.


sudo make install-daemoninit


Information on starting and stopping services will be explained further on.

Install Command Mode - This installs and configures the external command file.

sudo make install-commandmode


Install Configuration Files
This installs the *SAMPLE* configuration files. These are required as Nagios needs some configuration files to allow it to start.


sudo make install-config


Install Apache Config Files
This installs the Apache web server configuration files and configures Apache settings.


sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi


To Configure Firewall - You need to allow port 80 inbound traffic on the local firewall so you can reach the Nagios Core web interface.

sudo ufw allow Apache
sudo ufw reload


Create nagiosadmin User Account

You'll need to create an Apache user account to be able to log into Nagios.

The following command will create a user account called nagiosadmin and you will be prompted to provide a password for the account.


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




When adding additional users in the future, you need to remove -c from the above command otherwise it will replace the existing nagiosadmin user (and any other users you may have added).

Start Apache Web Server

===== Ubuntu 14.x =====


Need to restart it because it is already running.

sudo service apache2 restart


===== Ubuntu 15.x / 16.x / 17.x /18.x =====

Need to restart it because it is already running.


sudo systemctl restart apache2.service

Start Service / Daemon

This command starts Nagios Core.


===== Ubuntu 14.x =====

sudo start nagios


===== Ubuntu 15.x / 16.x / 17.x / 18.x =====


sudo systemctl start nagios.service


Test Nagios

Nagios is now running, to confirm this you need to log into the Nagios Web Interface.

Point your web browser to the ip address or FQDN of your Nagios Core server, for example:

http://192.168.1.111/nagios

http://nagios.domain.local/nagios

You will be prompted for a username and password. The username is nagiosadmin (you created it in a previous step) and the password is what you provided earlier.

Once you have logged in you are presented with the Nagios interface. Congratulations you have installed Nagios Core.