Nagios Remote Host Monitoring
Nagios Remote Host Monitoring
Dated on :05/10/2018
On Remote Host
Step 1: Install the compiler gcc,glibc
yum install -y gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel
Step 2: Add the user for the nagios using
useradd nagios
Note: If already exist skip this.
Step 3: Add the password for created user
passwd nagios
Note: Then give the New password and then confirm the new password
Step 4: Create Directory using
mkdir /root/nagios
Step 5: Go to the created directory
cd /root/nagios
Step 6: Install the Nagios Plugins
wget https://www.nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
Note : choose the file name upto your choice . If you want the latest version find the path and give the path.
Step 7: Extract nagios plugin using tar command
tar -xvf nagios-plugins-2.2.1.tar.gz
Step 8: Check whether the folder appear in the directory
ls –l
Step 9: Compile and install nagios using
Step 9.1: Go to cd nagios-plugins-2.2.1
Step 9.2: User editor to edit the ./configure
Step 9.3: Add make and make all
Step 10: Set the permission on the plugin directory
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec
Step 11: install xinetd service using
yum install xinetd
Step 12: install NRPE plugin on the remote host machine
wget http://liquidtelecom.dl.sourceforge.net/project/nagios/nrpe-3.x/nrpe-3.1.1/nrpe-3.1.1.tar.gz
NOTE: choose the latest version if you wish
Step 13: unpack NRPE source file using tar command
tar xzf nrpe-3.1.1.tar.gz
Compile and install the NRPE addon
———————————————
Step 14: Go to
cd nrpe-3.1.1
Step 15: edit the file using editor
./configure
Step 16: Add make all
install the NRPE plugin daemon, and sample daemon config file
Step 17: Install plugin
make install-plugin
Step 18: Install daemon
make install-daemon
Step 19: make install-daemon-config
Install the NRPE daemon under xinetd as a service
Step 20: make install-xinetd
OR
make install-inetd
Now open /etc/xinetd.d/nrpe
file and add the localhost and IP address of the Nagios Monitoring Server.
Step 21: only_from = 127.0.0.1 <nagios_ip_address>
Step 22: Next, open /etc/services file add the following entry for the NRPE daemon at the bottom of the file.
nrpe 5666/tcp NRPE
Step 23:Restart the xinetd service
service xinetd restart
Step 24:Verify NRPE Daemon Locally
netstat -at | grep nrpe
Step 25: Run the “check_nrpe” command
/usr/local/nagios/libexec/check_nrpe -H <localhost IP ex:127.0.0.1>
Note: you will the output as NRPE v3.2.1. Version will change it belongs the tar file which you downloaded.
Configure Firewall Rules
Step 26: ————– On RHEL/CentOS 6/5 and Fedora ————–
iptables -A INPUT -p tcp -m tcp --dport 5666 -j ACCEPT
———- On RHEL/CentOS 7 and Fedora 19 Onwards ————–
firewall-cmd --permanent --zone=public --add-port=5666/tcp
Run the following command to Save the new iptables rule
Step 27: ————– On RHEL/CentOS 6/5 and Fedora ————–
service iptables save
On Nagios Monitoring Server
Step 1: Go to
cd /root/nagios
Step 2: Get the software
wget http://liquidtelecom.dl.sourceforge.net/project/nagios/nrpe-3.x/nrpe-3.1.1/nrpe-3.1.1.tar.gz
Step 3: Unpack the NRPE source code tarball.
tar xzf nrpe-3.1.1.tar.gz
Step 4: Go to cd nrpe-3.0
Compile and install the NRPE addon.
Step 5: ./configure
Step 6: make all
Step 7: make install-daemon
Verify NRPE Daemon Remotely
Step 8: Go to the location
/usr/local/nagios/libexec/check_nrpe -H <remote_linux_ip_address>
Step 9: Edit using vi editor
vi /usr/local/nagios/etc/servers/hostname.cfg
Note: you have a different host name so change the hostname in the config file.
Step 10: Define the host name and the service in the config file
define host { use linux-server host_name example_01 alias example_01 address xxx.xxx.xxx.xxx max_check_attempts 5 check_period 24x7 notification_interval 30 notification_period 24x7 } define service { use generic-service,nagiosgraph host_name example_01 service_description PING check_command check_ping!100.0,20%!500.0,60% } define service { use generic-service,nagiosgraph host_name example_01 service_description SSH check_command check_ssh notifications_enabled 0 } define service { use generic-service,nagiosgraph host_name example_01 service_description Nginx check_command check_tcp!80 } define service{ use generic-service,nagiosgraph host_name example_01 service_description Load check_command check_nrpe!check_load } define service{ use generic-service,nagiosgraph host_name example_01 service_description Disk check_command check_nrpe!check_disk } define service{ use generic-service,nagiosgraph host_name example_01 service_description Processes check_command check_nrpe!check_procs } define service{ use generic-service,nagiosgraph host_name example_01 service_description Uptime check_command check_nrpe!check_uptime } define service{ use generic-service,nagiosgraph host_name example_01 service_description Memory check_command check_nrpe!check_mem } define service{ use generic-service,nagiosgraph host_name example_01 service_description uWSGI check_command check_nrpe!check_uwsgi }