Sunday 4 November 2018

How to add Linux Host to Nagios Monitoring Server in CentOS 7

Nagios plugins and NRPE are available for Cent OS 7 and RHEL in EPEL repository (Extra Packages for Enterprise Linux).
Setup EPEL repository: follow tutorial How to install EPEL repository on Centos7

Step 1: Run the following command to install NRPE and Nagios plugins:

[root@linuxcnf ~]# yum install nagios-plugins nrpe

Step 2: Configure NRPE to allow communication with Nagios Server:

Open NRPE configuration file /etc/nagios/nrpe.cfg and add the Nagios server in allowed_hosts:

[root@linuxcnf ~]# vi /etc/nagios/nrpe.cfg
[root@linuxcnf ~]#

Save the file and exit.

Step 3: Start NRPE service and enable on OS boot up:

[root@linuxcnf ~]# service nrpe start
Redirecting to /bin/systemctl start nrpe.service
[root@linuxcnf ~]# chkconfig nrpe on
Note: Forwarding request to 'systemctl enable nrpe.service'.
[root@linuxcnf ~]#

Step 4: Adding the host to the Nagios Server:

Now configure the host on Nagios server to check the remote host status. Open below file and paste the below into the file

[root@linuxcnf ~]# vi /usr/local/nagios/etc/servers/host.cfg
define host{
        use                          linux-server           
        host_name               Server-Name
        alias                        Server-Name
        contacts                  nagiosadmin

define service{
        use                         generic-service
        host_name              Server-Name
        service_description PING
        check_command     check-host-alive
[root@linuxcnf ~]#

Save the file and exit.

Step 5: Check syntax errors (pre-flight check) and Restart NRPE service: Now restart NRPE to reflect the changes:

[root@linuxcnf ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/servers/host.cfg
Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
[root@linuxcnf ~]# service nagios reload
Reloading nagios configuration (via systemctl):            [  OK  ]
[root@linuxcnf ~]#

Configuration is done. Now the host status is available on Nagios admin portal.

No comments:

Post a Comment