Nagios: Monitor Hosts and Services (Part-2)

Add monitoring targets to Nagios Server (NRPE and nagios-plugin)

NRPE allows us to remotely execute Nagios plugins on other Linux/Unix machines. This allows us to monitor remote machine metrics (disk usage, CPU load, etc.). NRPE can also communicate with some of the Windows agent addons, so we can execute scripts and check metrics on remote Windows machines as well.
Now we shall add some clients to monitor by Nagios Server. To do that we have to install NRPE (Nagios Remote Plugin Executor) and nagios-plugins in our monitoring targets.

To install NRPE, add EPEL repository in our CentOS/RHEL 7.
# yum install epel-release
# yum install nrpe nagios-plugins-all openssl
# vi /etc/nagios/nrpe.cfg

## Find the following line and add the Nagios server IP ##

allowed_hosts=,’s ip), (client’s ip)
#systemctl start nrpe
#chkconfig nrpe on

Edit “/usr/local/nagios/etc/nagios.cfg” file

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

### Find and uncomment the following line ###


Now create a directory called “servers” under “/usr/local/nagios/etc/”.

# mkdir /usr/local/nagios/etc/servers

Now create config file to the client to be monitored:
# vi /usr/local/nagios/etc/servers/client01.cfg
define host {
use linux-server
host_name client01
alias client01
max_check_attempts 5
check_period 24×7
notification_interval 30
notification_period 24×7
contacts_group admins
contacts nagiosadmin
define service {
use generic-service
host_name client01
service_description SSH
check_command check_ssh
notifications_enabled 1
contacts_group admins
contacts nagiosadmin

# systemctl restart nagios

To permission CGI file for nagiosadmin user to view the current status of all hosts and services that are being monitored.
# vim /usr/local/nagios/etc/cgi.cfg

To configure email alert/notification in Nagios Server
# yum install ssmtp sendmail –y
# /etc/init.d/sendmail stop ; chkconfig sendmail off
# cp -p /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.bk
# vi /etc/ssmtp/ssmtp.conf

–Add the below items in the files—

— Take backup of sendmail script —

# cp -p /usr/sbin/sendmail /usr/sbin/sendmail.bk
# cd /usr/sbin
# ln -s /usr/sbin/ssmtp sendmail

# /etc/init.d/nagios restart

See More at Nagios: Monitor Hosts and Services (Part-3)