Hosts
## Install nrpe
yum install openssl-devel xinetd unzip
# Download nrpe
cd /tmp
curl -L -O http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
------
[root@dlp ~]# vi /etc/nagios/nagios.cfg
# line 51: uncomment
cfg_dir=/etc/nagios/servers
[root@dlp ~]# mkdir /etc/nagios/servers
[root@dlp ~]# chgrp nagios /etc/nagios/servers
[root@dlp ~]# chmod 750 /etc/nagios/servers
[root@dlp ~]# vi /etc/nagios/servers/node01.cfg
# create new
define host{ use linux-server host_name node01 alias node01 address 10.0.0.51 } define service{ use generic-service host_name node01 service_description PING check_command check_ping!100.0,20%!500.0,60% }
[root@dlp ~]# systemctl restart nagios
-------------------------------X------------------------------------
# yum install nrpe nagios-plugins*
vi /etc/nagios/nrpe.cfg
#Add Nagios Server IP
allowed_hosts=127.0.0.1, 172.17.20.100
systemctl restart nrpe.service
or
service nrpe restart
make all
make install
make install-xinetd
make install-daemon-config
# Test nrpe client
telnet <client ip> 5666
/usr/local/nagios/libexec/check_nrpe -H 172.17.25.100
Step 6:
# Configure HOST
vi /usr/local/nagios/etc/servers/webserver.linuxtopic.cfg
## Host Details ###
define host {
use linux-server
host_name webserver.linuxtopic.com
alias MyWeb
address 172.17.20.103
max_check_attempts 10
check_period 24x7
notification_interval 10 # Notification
notification_period 24x7
}
# Define Group
define hostgroup{
hostgroup_name Webserver_Group
alias MyWebserver
# members 172.17.20.103
}
####
# Check Ping
define service {
use generic-service
host_name webserver.linuxtopic.com
service_description PING
check_command check_ping!100.0,20%!500.0,60%
check_interval 1 # 1 min
retry_interval 1 # 1 min
}
# Define a service to check the load on the local machine.
define service{
use local-service
host_name webserver.linuxtopic.com
service_description Current Load
check_command check_nrpe!check_load!15.0,12.0,10.0!20.0,18.0,15.0
check_interval 1
retry_interval 1
}
# Check Users
define service{
use generic-service
host_name webserver.linuxtopic.com
service_description Current Users
check_command check_nrpe!check_users
check_interval 1
retry_interval 1
}
# Check Process
define service{
use local-service
host_name webserver.linuxtopic.com
service_description Total Processes
check_command check_nrpe!check_total_procs!250!400!RSZDT
check_interval 1
retry_interval 1
}
# Check Root Part.
define service{
use local-service
host_name webserver.linuxtopic.com
service_description Disk-Root-Partition
check_command check_nrpe!check_root!10%!5%!/
check_interval 1
retry_interval 1
}
# Define a service to check the swap usage the local machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free
define service{
use local-service
host_name webserver.linuxtopic.com
service_description Disk-Swap-Partition
check_command check_nrpe!check_swap!20!10
check_interval 1
retry_interval 1
}
## Check HTTP Server
define service{
use local-service
host_name webserver.linuxtopic.com
service_description WEB-HTTP
check_command check_nrpe!check_http
check_interval 1
retry_interval 1
}
---------------------------------------------X-------------------------------------
Adding Remote Linux Host to Nagios Monitoring Server
To add a remote host you need to create a two new files “hosts.cfg” and “services.cfg” under “/usr/local/nagios/etc/” location.
[[email protected]]# cd /usr/local/nagios/etc/ [[email protected]]# touch hosts.cfg [[email protected]]# touch services.cfg
Now add these two files to main Nagios configuration file. Open nagios.cfg file with any editor.
[[email protected]]# vi /usr/local/nagios/etc/nagios.cfg
Now add the two newly created files as shown below.
# You can specify individual object config files as shown below: cfg_file=/usr/local/nagios/etc/hosts.cfg cfg_file=/usr/local/nagios/etc/services.cfg
Now open hosts.cfg file and add the default host template name and define remote hosts as shown below. Make sure to replace host_name, alias and address with your remote host server details.
[[email protected]]# vi /usr/local/nagios/etc/hosts.cfg
## Default Linux Host Template ## define host{ name linux-box ; Name of this template use generic-host ; Inherit default values check_period 24x7 check_interval 5 retry_interval 1 max_check_attempts 10 check_command check-host-alive notification_period 24x7 notification_interval 30 notification_options d,r contact_groups admins register 0 ; DONT REGISTER THIS - ITS A TEMPLATE } ## Default define host{ use linux-box ; Inherit default values from a template host_name tecmint ; The name we're giving to this serveralias CentOS 6 ; A longer name for the serveraddress 5.175.142.66 ; IP address of Remote Linux host }
Next open services.cfg file add the following services to be monitored.
[[email protected]]# vi /usr/local/nagios/etc/services.cfg
define service{ use generic-service host_name tecmint service_description CPU Load check_command check_nrpe!check_load } define service{ use generic-service host_name tecmint service_description Total Processes check_command check_nrpe!check_total_procs } define service{ use generic-service host_name tecmint service_description Current Users check_command check_nrpe!check_users } define service{ use generic-service host_name tecmint service_description SSH Monitoring check_command check_nrpe!check_ssh } define service{ use generic-service host_name tecmint service_description FTP Monitoring check_command check_nrpe!check_ftp }
Now NRPE command definition needs to be created in commands.cfg file.
[[email protected]]# vi /usr/local/nagios/etc/objects/commands.cfg
Add the following NRPE command definition at the bottom of the file.
############################################################################### # NRPE CHECK COMMAND # # Command to use NRPE to check remote host systems ############################################################################### define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }
Finally, verify Nagios Configuration files for any errors.
[[email protected]]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Total Warnings: 0 Total Errors: 0
Restart Nagios:
[[email protected]]# service nagios restart
That’s it. Now go to Nagios Monitoring Web interface at “http://Your-server-IP-address/nagios” or “http://FQDN/nagios” and Provide the username “nagiosadmin” and password. Check that the Remote Linux Host was added and is being monitored.
--------