Author Photo

Ahmer's SysAdmin Recipes is a blog for Linux System Administrators. This blog provides recipes for Installation & Configuration of Linux, Ubuntu, Oracle Database, MySQL, Apache, Nginx, Oracle Cloud Control, FreeIPA, Kerberos & OpenLDAP, Subversion, PXE, DevOps, etc. over Red Hat Enterprise Linux (RHEL), CentOS, Ubuntu and Windows.

Please give me your feedback and help me improve this blog. Please let me know If you want me to write on a specific topic.

Sunday, 11 September 2016

Install NRPE Nagios Core Agent on CentOS 7

Install NRPE Nagios Core Agent on CentOS 7 We have already configured our Nagios Monitoring Server in our previous post Install & Configure Nagios Core 4.4 on CentOS 7. Now, its time to add some hosts to our Nagios Monitoring Server. For this purpose, we need to install a Monitoring Agent software on our Host. There are so many Monitoring Agents are available, that works well with not only Nagios, but other forks of Nagios (such as Icinga). But after having some research we have selected NRPE (Nagios Remote Process Executor) for the purpose.

In this post, we will install NRPE Nagios Core Agent on CentOS 7 host to add it to Nagios Monitoring Server.

Before moving forward, it is required to have basic concepts of Nagios Core 4. Therefore, it is highly recommended that you should have Learning Nagios - Third Edition. It will be really helpful for you during your Nagios journey.

 

System Specification:

1) Nagios Monitoring Server – A working Nagios Core Server.

Hostname: nagios01.example.com
IP Address: 192.168.229.129/24

2) Linux Host – A CentOS 7 machine, in which we are going to install NRPE.

Hostname: dbserver01.example.com
IP Address: 192.168.229.133/24

 

Install and Configure NRPE Nagios Core Agent on CentOS 7:

Connect to the Linux host using ssh and install prerequisite packages.

[root@dbserver01 ~]# yum install -y gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel

Create user that own Nagios plugins and NRPE files & processes.

[root@dbserver01 ~]# useradd nagios [root@dbserver01 ~]# passwd nagios

Create directories to download Nagios plugins & NRPE.

[root@dbserver01 ~]# mkdir -p /soft/nagios

Download Nagios Plugins 2.1.2 from https://www.nagios.org/downloads/nagios-plugins/

[root@dbserver01 ~]# cd /soft/nagios [root@dbserver01 nagios]# wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz

Extract and install Nagios plugins.

[root@dbserver01 nagios]# tar -xvf nagios-plugins-2.1.2.tar.gz [root@dbserver01 nagios]# cd nagios-plugins-2.1.2 [root@dbserver01 nagios-plugins-2.1.2]# ./configure [root@dbserver01 nagios-plugins-2.1.2]# make [root@dbserver01 nagios-plugins-2.1.2]# make install

Download NRPE Agent from Nagios Exchange.

[root@dbserver01 ~]# cd /soft/nagios [root@dbserver01 nagios]# wget https://github.com/NagiosEnterprises/nrpe/archive/3.0.1.tar.gz

Extract and install NRPE.

[root@dbserver01 nagios]# tar -xvzf 3.0.1.tar.gz [root@dbserver01 nagios]# cd nrpe-3.0.1/ [root@dbserver01 nrpe-3.0.1]# ./configure [root@dbserver01 nrpe-3.0.1]# make all [root@dbserver01 nrpe-3.0.1]# make install-daemon

Open the server port, used by NRPE Daemon.

[root@dbserver01 nrpe-3.0.1]# firewall-cmd –-permanent –-add-port=5666/tcp success [root@dbserver01 nrpe-3.0.1]# firewall-cmd –reload success

Configure NRPE.

[root@dbserver01 nrpe-3.0.1]# mkdir /usr/local/nagios/etc/ [root@dbserver01 nrpe-3.0.1]# cp sample-config/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg [root@dbserver01 nrpe-3.0.1]# vi /usr/local/nagios/etc/nrpe.cfg

Add the localhost (IPv4 & IPv6 both) & Nagios Monitoring Server IP addresses separated by Comma ','.

allowed_hosts=127.0.0.1,::1,192.168.229.129

Start the NRPE Daemon.

[root@dbserver01 nrpe-3.0.1]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

At Nagios Monitoring Server add this Linux host and define some services.

[root@nagios01 ~]# vi /usr/local/nagios/etc/objects/linux.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 dbserver01 ; The name we're giving to this server alias dbserver01 ; A longer name for the server address 192.168.229.133 ; IP address of Remote Linux host } define service{ use generic-service host_name dbserver01 service_description CPU Load check_command check_nrpe!check_load } define service{ use generic-service host_name dbserver01 service_description Total Processes check_command check_nrpe!check_total_procs } define service{ use generic-service host_name dbserver01 service_description Current Users check_command check_nrpe!check_users } define service{ use generic-service host_name dbserver01 service_description SSH Monitoring check_command check_nrpe!check_ssh } define service{ use generic-service host_name dbserver01 service_description FTP Monitoring check_command check_nrpe!check_ftp }

Now, add this config file to nagios.cfg.

[root@nagios01 ~]# vi /usr/local/nagios/etc/nagios.cfg

cfg_file=/usr/local/nagios/etc/objects/linux.cfg

Define the check_nrpe command.

[root@nagios01 ~]# vi /usr/local/nagios/etc/objects/commands.cfg

define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }

Restart Nagios service to reload changes

[root@nagios01 ~]# systemctl restart nagios.service

Browse the Nagios Web UI, and check the services of dbserver01.

Nagios Core Web UI

NRPE Nagios Core Agent has been successfully installed on our CentOS 7 host.

Install NRPE Nagios Core Agent on CentOS 7


YOU MIGHT ALSO LIKE:

8 comments:

  1. would you mind i want to know what we need to install nrpe on nagios server. thanks.

    ReplyDelete
  2. would you mind i want to know what we need to install nrpe on nagios server.thanks sir

    ReplyDelete
    Replies
    1. You are welcome Htet. Installation of NRPE is not required on Nagios Server, because Local System metrics directly collected by Nagios itself.

      Delete
  3. Thanks a lot MR ahmer,
    I think i need two system :
    The first : Nagios core 4, plugins 2
    The second : plugins 2, nrpe
    That is true ??

    ReplyDelete
    Replies
    1. Yes, you are right.

      Infact, we need NRPE on every client system, that we want to monitor with Nagios Core Server.

      Delete
    2. thank you so much ,
      i'm sorry i have other question about this line :
      vi /usr/local/nagios/etc/objects/linux.cfg
      is not working for me .
      what can i do ?

      Delete
    3. Contact me on Facebook please.

      Delete
    4. This comment has been removed by the author.

      Delete