Showing posts with label nrpe. Show all posts
Showing posts with label nrpe. Show all posts

Wednesday, October 21, 2020

Install PNP4Nagios for adding a graph to Nagios




Nagios offers monitoring and alerting services for your business infrastructures like servers, switches, applications and services. Adding a graph to Nagios is necessary for effective monitoring especially to predict possible attacks on your servers. PNP4Nagios is a plugin for Nagios for creating graphs.

Click here to learn how to install Nagios Core.

Step 1: Install all required package

yum install rrdtool perl-Time-HiRes rrdtool-perl php-gd -y

Step 2: Download the source and extract 

cd /tmp

wget https://sourceforge.net/projects/pnp4nagios/files/latest/download/pnp4nagios-0.6.26.tar.gz

tar zxfv pnp4nagios-0.6.26.tar.gz

Step 3: Compile and Install 

cd pnp4nagios-0.6.26

./configure

make all

make fullinstall

Step 4: Setup the NPCD

Change config to run npcd only on level 3 and 5. Change also the install.php filename.

chkconfig --add npcd && chkconfig --level 35 npcd on 

service httpd reload

Check the URL http: // server / pnp4nagios / to make sure pnp4nagios has been installed. If all green and pass then proceed.

Backup install.php

mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php-ori

Step 5: Edit nagios.cfg, and add this at the bottom of the file 

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

[Esc]+ GA – to edit the bottom of the file

# Bulk / NPCD mode 

process_performance_data=1 

service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata 

service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECH$ 

service_perfdata_file_mode=a 

service_perfdata_file_processing_interval=15 

service_perfdata_file_processing_command=process-service-perfdata-file


host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata 

host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$ host_perfdata_file_mode=a 

host_perfdata_file_processing_interval=15 

host_perfdata_file_processing_command=process-host-perfdata-file

[Esc] :wq

Step 6: Edit commands.cfg

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

[Esc]+ GA

define command{ 

command_name process-service-perfdata-file 

command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$ 

}


define command{ 

command_name process-host-perfdata-file 

command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$ 

}

Step 7: Edit templates.cfg and add host-pnp & srv-pnp

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

define host { 

name host-pnp 

action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_ 

register 0 

}

define service { 

name srv-pnp 

action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$ 

register 0 

}

Put the host-pnp on every host like this:

define host{

        use                     linux-server,host-pnp

        host_name               localhost

        alias                   localhost

        address                 127.0.0.1

        }

Put the srv-pnp on every service like this:

define service{

        use                             local-service,srv-pnp         

        host_name                       localhost

        service_description             PING

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

}

Step 8: Copy the status-header and restart services

Copy this file in the /usr/local/nagios/share/ssi/ for mouseover graph

cp contrib/ssi/status-header.ssi /usr/local/nagios/share/ssi/

Then restart npcd,httpd and nagios

service npcd restart

service httpd restart

service nagios restart 


 

Thursday, October 15, 2020

How to Install NRPE on Centos 6.4

 


NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines. This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). NRPE can also communicate with some of the Windows agent addons, so you can execute scripts and check metrics on remote Windows machines as well.

Check how to install Nagios Core here.

Step 1: Install first the required package for NRPE

yum install -y gcc glibc glibc-common openssl openssl-devel perl wget

Step 2: Download the source, extract, compile and install 

Download the package.

cd /tmp

wget --no-check-certificate -O nrpe.tar.gz

https://github.com/NagiosEnterprises/nrpe/
archive/nrpe-3.2.1.tar.gz

Extract 

tar xzf nrpe.tar.gz

cd nrpe-nrpe-3.2.1/

 Compile & Install

./configure --enable-command-args

make all

make install-groups-users

make install

make install-config

Update Services File and finish the installation.

echo >> /etc/services

echo '# Nagios services' >> /etc/services

echo 'nrpe    5666/tcp' >> /etc/services

make install-init

Step 3: Configure firewall 

Configure firewall rules and open port 5666 for NRPE.

iptables -I INPUT -p tcp --destination-port 5666 -j
 ACCEPT

service iptables save

service iptables restart

Step 4: Update nrpe.cfg 

The allowed_hosts on Nagios Server doesn't need to change but make sure to configure it and put the Nagios Server IP when you installed NRPE on Nagios clients.

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

allowed_hosts=127.0.0.1,192.168.1.67

dont_blame_nrpe=1

Step 5: Start the service 

Start the NRPE service then run test.

start nrpe

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

The result will be:

NRPE v3.2.1