In this sample, Nagios monitors remote Linux host via the plugin named ‘check_nrpe’. And the NRPE package needs to be installed on the remote Linux host, as it works as the Nagios Linux agent.
* The following configurations need to be done on the remote Linux/Unix host:
1) Install prerequisite packages.
yum install -y gcc glibc glibc-common yum install -y openssl-devel
2) Create nagios account
useradd nagios passwd nagios
3) Download and install nagios plugins.
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz tar xvzf nagios-plugins-1.4.11.tar.gz cd nagios-plugins-1.4.11 export LDFLAGS=-ldl ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround make make install chown nagios.nagios /usr/local/nagios chown -R nagios.nagios /usr/local/nagios/libexec/
4) Download and install NRPE.
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz tar xvfz nrpe-2.12.tar.gz cd nrpe-2.12 ./configure make all make install-plugin make install-daemon make install-daemon-config make install-xinetd
5) Setup NRPE to run as daemon.
vi /etc/xinetd.d/nrpe add the nagios server IP here: only_from = 127.0.0.1 10.1.1.104 vi /etc/services add this line: nrpe 5666/tcp #NRPE service xinetd restart
6) Modify the nrpe.cfg configuration file if you want to customize it.
vi /usr/local/nagios/etc/nrpe.cfg
* The following configurations need to be done on the Nagios server:
1) Download and install the NRPE plugin.
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz tar xvfz nrpe-2.12.tar.gz cd nrpe-2.12 ./configure make all make install-plugin
2) Create host and service for the remote Linux host.
vi /usr/local/nagios/etc/objects/linux.cfg # host definition define host{ use linux-server host_name RHEL02 alias RHEL02 address 10.1.1.102 ;remote linux server IP address contact_groups admins } # service definition define service{ use generic-service host RHEL02 service_description Root Partition contact_groups admins check_command check_nrpe!check_local_disk }
3) Edit the command.cfg and nagios.cfg files.
vi /usr/local/nagios/etc/objects/commands.cfg Add the following lines: # check_nrpe define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } vi /usr/local/nagios/etc/nagios.cfg Add the following lines: # Definitions for monitoring a Linux machine cfg_file=/usr/local/nagios/etc/objects/linux.cfg
4) Verfiy the nagios configurations.
alias verinagios='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg' verinagios
* you can make the alias permanent by adding alias verinagios=’/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg’ to your profile ~/.bashrc
4) Reload the nagios service.
service nagios reload
Here we go. The newly added Linux host should be listed in the monitored hosts now: