{"id":742,"date":"2018-09-29T11:19:46","date_gmt":"2018-09-29T08:19:46","guid":{"rendered":"http:\/\/kifarunix.com\/?p=742"},"modified":"2024-03-11T19:33:46","modified_gmt":"2024-03-11T16:33:46","slug":"how-to-install-nagios-nrpe-agent-on-rhel-centos-oracle-linux","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-nagios-nrpe-agent-on-rhel-centos-oracle-linux\/","title":{"rendered":"Install Nagios NRPE Agent on RHEL\/CentOS\/Oracle Linux"},"content":{"rendered":"\n<p>In this tutorial, we are going to learn how to install Nagios NRPE Agent on RHEL\/CentOS\/Oracle Linux. Nagios Remote Plugin Executor (NRPE) <span class=\"ILfuVd\">is used to remotely execute Nagios plugins on Linux\/Unix machines. This makes it easy to monitor remote machine metrics such as disk usage, CPU load, number of running processes, logged in users etc.<\/span><\/p>\n\n\n\n<p>You may also want to check our previous article on <a href=\"https:\/\/kifarunix.com\/how-to-configure-availability-monitoring-on-alienvault-usm-ossim\/\" target=\"_blank\" rel=\"noopener noreferrer\">how to configure Nagios Aviailability monitoring on AlienVault USM\/OSSIM<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-nagios-nrpe-agent-on-rhel-cent-os-oracle-linux\">Installing Nagios NRPE Agent on RHEL\/CentOS\/Oracle Linux<\/a><ul><li><a href=\"#install-required-build-tools\">Install Required Build tools<\/a><\/li><li><a href=\"#download-nrpe-source-file\">Download NRPE Source File<\/a><\/li><li><a href=\"#extract-nrpe-source-file\">Extract NRPE Source File<\/a><\/li><li><a href=\"#installing-nagios-nrpe-agent\">Installing Nagios NRPE Agent<\/a><ul><li><a href=\"#configure-nrpe\">Configure NRPE<\/a><\/li><li><a href=\"#create-user-and-group\">Create User And Group<\/a><\/li><li><a href=\"#compile-nrpe\">Compile NRPE<\/a><\/li><li><a href=\"#install-nagios-nrpe-agent\">Install Nagios NRPE Agent<\/a><\/li><li><a href=\"#install-nrpe-configuration-file-and-service\">Install NRPE Configuration File and Service<\/a><\/li><li><a href=\"#define-nrpe-service-port-and-protocol\">Define NRPE Service, Port and Protocol<\/a><\/li><li><a href=\"#allow-nrpe-through-firewall\">Allow NRPE through firewall<\/a><\/li><li><a href=\"#start-and-enable-nrpe-to-run-on-system-boot\">Start and Enable NRPE to run on System boot<\/a><\/li><li><a href=\"#install-nagios-plugins-on-cent-os-rhel-oracle-rocky-linux\">Install Nagios Plugins on CentOS\/RHEL\/Oracle\/Rocky Linux<\/a><\/li><li><a href=\"#configure-nrpe-on-cent-os-rhel-oracle-rocky-linux\">Configure NRPE on CentOS\/RHEL\/Oracle\/Rocky Linux<\/a><\/li><li><a href=\"#test-the-plugins\">Test the Plugins<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-nagios-nrpe-agent-on-rhel-cent-os-oracle-linux\">Installing Nagios NRPE Agent on RHEL\/CentOS\/Oracle Linux<\/h2>\n\n\n\n<p>This tutorial installs NRPE by building it from the source code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-required-build-tools\">Install Required Build tools<\/h3>\n\n\n\n<p>As a prerequisite, ensure that the C compilers and are installed on the server since we are compiling NRPE from the source code;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>yum install -y gcc glibc glibc-common openssl openssl-devel<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"download-nrpe-source-file\">Download NRPE Source File<\/h3>\n\n\n\n<p>Navigate to <a href=\"https:\/\/github.com\/NagiosEnterprises\/nrpe\/releases\" target=\"_blank\" rel=\"noreferrer noopener\">NRPE releases page<\/a> and grab the latest source code.<\/p>\n\n\n\n<p>Run the command below to download NRPE source file under the \/tmp directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/github.com\/NagiosEnterprises\/nrpe\/releases\/download\/nrpe-4.1.0\/nrpe-4.1.0.tar.gz -P \/tmp\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"extract-nrpe-source-file\">Extract NRPE Source File<\/h3>\n\n\n\n<p>Once the download is complete, navigate to the download directory and run the command below to extract the source file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd \/tmp\ntar zxvf nrpe-4.1.0.tar.gz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-nagios-nrpe-agent\">Installing Nagios NRPE Agent<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"configure-nrpe\">Configure NRPE<\/h4>\n\n\n\n<p>In order to compile NRPE package, you first need to set all the options and dependencies required&nbsp; for the rest of the build and install process.<\/p>\n\n\n\n<p>Run the command below to configure NRPE program;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd nrpe-4.1.0\n.\/configure --enable-command-args --with-nrpe-user=nagios --with-nrpe-group=nagios<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>&#8211;enable-command-args<\/strong> options enables you to pass arguments through NRPE. If omitted, then the arguments have to be explicitly set on the nrpe configuration file, nrpe.cfg.<\/li>\n\n\n\n<li><strong>&#8211;with-nrpe-user=nagios &#8211;with-nrpe-group=nagios<\/strong> sets the ownership of the configuration files.<\/li>\n<\/ul>\n\n\n\n<p>If for some reason you encounter an issue during compilation regarding openssl, run thw compilation with <strong>&#8211;disable-ssl option<\/strong>.<\/p>\n\n\n\n<p>If the compilation is successful, you should see the sample output below.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\n...\n General Options:\n -------------------------\n NRPE port:    5666\n NRPE user:    nagios\n NRPE group:   nagios\n Nagios user:  nagios\n Nagios group: nagios\n\n\nReview the options above for accuracy.  If they look okay,\ntype 'make all' to compile the NRPE daemon and client\nor type 'make' to get a list of make options.\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-user-and-group\">Create User And Group<\/h4>\n\n\n\n<p>The ownership of the configuration files is set to <strong>nagios:nagios <\/strong> above&nbsp;. You therefore need to create the nagios user and group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-groups-users<\/code><\/pre>\n\n\n\n<p>To confirm that the user and the group is actually created, run id command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>id nagios<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>uid=1000(nagios) gid=989(nagios) groups=989(nagios)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"compile-nrpe\">Compile NRPE<\/h4>\n\n\n\n<p>If the above compilation options are fine, run the command below to compile the NRPE daemon and client.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make all<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-nagios-nrpe-agent\">Install Nagios NRPE Agent<\/h4>\n\n\n\n<p>Once the compilation process is done, continue to install NRPE Daemon and the check_nrpe plugin.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-nrpe-configuration-file-and-service\">Install NRPE Configuration File and Service<\/h4>\n\n\n\n<p>Run the following commands to install NRPE sample configuration file as well as the NRPE service.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-config\nmake install-init<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"define-nrpe-service-port-and-protocol\">Define NRPE Service, Port and Protocol<\/h4>\n\n\n\n<p>Edit the service configuration file and map the nrpe service to its specific port and protocol, 5666\/tcp by adding the following line at the bottom.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>echo \"<strong>nrpe            5666\/tcp                # NRPE Service<\/strong>\" &gt;&gt; \/etc\/services<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"allow-nrpe-through-firewall\">Allow NRPE through firewall<\/h4>\n\n\n\n<p>NRPE uses port TCP 5666 by default. If firewall is running, open this port.<\/p>\n\n\n\n<p>For Firewalld;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>firewall-cmd --add-port=5666\/tcp --permanent\nfirewall-cmd --reload<\/code><\/pre>\n\n\n\n<p>For IPTables;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted screen\">iptables -I INPUT -p tcp --dport 5666 -j ACCEPT\niptables-save &gt; \/etc\/sysconfig\/iptables<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"start-and-enable-nrpe-to-run-on-system-boot\">Start and Enable NRPE to run on System boot<\/h4>\n\n\n\n<p>Run the commands below to start and enable nrpe to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl start nrpe\nsystemctl enable nrpe<\/code><\/pre>\n\n\n\n<p>You can check the status of NRPE agent as shown below;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\n\u25cf nrpe.service - Nagios Remote Plugin Executor\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/nrpe.service; enabled; vendor preset: disabled)\n   Active: active (running) since Wed 2021-06-23 13:54:18 EAT; 14s ago\n     Docs: http:\/\/www.nagios.org\/documentation\n Main PID: 7719 (nrpe)\n    Tasks: 1 (limit: 11387)\n   Memory: 728.0K\n   CGroup: \/system.slice\/nrpe.service\n           \u2514\u25007719 \/usr\/local\/nagios\/bin\/nrpe -c \/usr\/local\/nagios\/etc\/nrpe.cfg -f\n\nJun 23 13:54:18 localhost.localdomain systemd[1]: Started Nagios Remote Plugin Executor.\nJun 23 13:54:18 localhost.localdomain nrpe[7719]: Starting up daemon\nJun 23 13:54:18 localhost.localdomain nrpe[7719]: Server listening on 0.0.0.0 port 5666.\nJun 23 13:54:18 localhost.localdomain nrpe[7719]: Server listening on :: port 5666.\nJun 23 13:54:18 localhost.localdomain nrpe[7719]: Listening for connections on port 5666\nJun 23 13:54:18 localhost.localdomain nrpe[7719]: Allowing connections from: 127.0.0.1,::1\n<\/code><\/pre>\n\n\n\n<p>Verify that NRPE port 5666 is open;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ss -altn | grep 5666<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>LISTEN     0      5            *:5666                     *:*                  \nLISTEN     0      5           :::5666                    :::*<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-nagios-plugins-on-cent-os-rhel-oracle-rocky-linux\">Install Nagios Plugins on CentOS\/RHEL\/Oracle\/Rocky Linux<\/h4>\n\n\n\n<p>In order to monitor various services, NRPE utilizes nagios plugins. Therefore you need to install Nagios Plugins before you can proceed to configure NRPE. You can check our previous article:<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/how-to-install-nagios-plugins-from-source-rhel-centos-oracle-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Nagios Plugins From Source RHEL\/CentOS\/Oracle Linux<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-nagios-plugins-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Nagios Plugins on Rocky Linux 8<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"configure-nrpe-on-cent-os-rhel-oracle-rocky-linux\"><a href=\"#configure-nrpe\">Configure NRPE on CentOS\/RHEL\/Oracle\/Rocky Linux<\/a><\/h4>\n\n\n\n<p>Once the Nagios plugins are installed, update NRPE configuration file. When installed from source, the configuration file will reside under, <strong>\/usr\/local\/nagios\/etc\/nrpe.cfg<\/strong>, although this can be changed.<\/p>\n\n\n\n<p>Therefore, edit the file and make the following changes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/usr\/local\/nagios\/etc\/nrpe.cfg<\/code><\/pre>\n\n\n\n<p>You may want to define a different IP address on which the service will listen on instead of the loopback. You can do so by changing the following line replacing loopback address with your interface IP address..<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>...\nserver_address=127.0.0.1<strong>\n...\n<\/strong><\/code><\/pre>\n\n\n\n<p>Under allowed hosts, replace the loopback6 address with Nagios Server IP such that the line looks like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>allowed_hosts=127.0.0.1,<strong>192.168.43.101<\/strong><\/code><\/pre>\n\n\n\n<p>Replace the <strong>dont_blame_nrpe=0<\/strong> setting with <strong>dont_blame_nrpe=1<\/strong> to allow command arguments.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dont_blame_nrpe=1<\/code><\/pre>\n\n\n\n<p>Next, you need to define the commands that will used to check for various system services. Note that these commands relies on the Nagios plugins installed above. You may comment out the existing commands and define your own, for example;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code><strong>command[check_users]=\/usr\/local\/nagios\/libexec\/check_users -w 5 -c 10<\/strong>\n<strong>command[check_load]=\/usr\/local\/nagios\/libexec\/check_load -r -w 8.0,7.5,7.0 -c 11.0,10.0,9.0<\/strong>\n<strong>command[check_disk]=\/usr\/local\/nagios\/libexec\/check_disk -w 15% -c 10% \/<\/strong>\n<strong>command[check_total_procs]=\/usr\/local\/nagios\/libexec\/check_procs -w 300 -c 400<\/strong>\n<strong>command[check_swap]=\/usr\/local\/nagios\/libexec\/check_swap -w 10 -c 5<\/strong><\/code><\/pre>\n\n\n\n<p>Save the configuration file once done editing and restrt NRPE service.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart nrpe<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"test-the-plugins\">Test the Plugins<\/h4>\n\n\n\n<p>Once you are done with installing the nagios plugins and configuring NRPE, execute the commands below to if all is well.<\/p>\n\n\n\n<p>Check the version of installed NRPE;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/usr\/local\/nagios\/libexec\/check_nrpe -H 127.0.0.1<\/code><\/pre>\n\n\n\n<p>You should get the NRPE version.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>NRPE v4.1.0<\/code><\/pre>\n\n\n\n<p>Check for running processes;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/usr\/local\/nagios\/libexec\/check_nrpe -H 127.0.0.1 -c check_total_procs<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>PROCS OK: 114 processes | procs=114;300;400;0;<\/code><\/pre>\n\n\n\n<p>Check for logged in users;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/usr\/local\/nagios\/libexec\/check_nrpe -H 127.0.0.1 -c check_users<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>USERS OK - 2 users currently logged in |users=2;5;10;0<\/code><\/pre>\n\n\n\n<p>Perfect, you are all set and good to go. That is all about Installing Nagios NRPE Agent on RHEL\/CentOS\/Oracle Linux. We hope this was informative.<\/p>\n\n\n\n<p>For other Related guides, see the links below;<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/monitor-linux-system-metrics-with-prometheus-node-exporter\/\" target=\"_blank\">Monitor Linux System Metrics with Prometheus Node Exporter<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/monitor-squid-logs-with-grafana-and-graylog\/\" target=\"_blank\">Monitor Squid logs with Grafana and Graylog<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/monitor-squid-access-logs-with-graylog-server\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Monitor Squid Access Logs with Graylog Server<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-install-nagios-plugins-and-nrpe-agents-on-centos-7-rhel-7-fedora-29\/\" target=\"_blank\">How to Install Nagios Plugins and NRPE agents on CentOS 7\/RHEL 7\/Fedora 29<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/monitor-linux-hosts-using-nagios-check_by_ssh-plugin\/\" target=\"_blank\">Monitor Linux Hosts using Nagios check_by_ssh Plugin<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-install-nagios-plugins-from-source-rhel-centos-oracle-linux\/\" target=\"_blank\">How to Install Nagios Plugins From Source RHEL\/CentOS\/Oracle Linux<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-and-setup-tig-stack-on-fedora-30\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install and Setup TIG Stack on Fedora 30<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we are going to learn how to install Nagios NRPE Agent on RHEL\/CentOS\/Oracle Linux. Nagios Remote Plugin Executor (NRPE) is used to<\/p>\n","protected":false},"author":1,"featured_media":9295,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[72,103,121,73],"tags":[1169,3733,3734,75,147,148],"class_list":["post-742","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-monitoring","category-alienvault","category-howtos","category-nagios","tag-install-nagios-nrpe-agent","tag-install-nrpe-centos","tag-install-nrpe-rocky-linux","tag-nagios","tag-nrpe","tag-nrpe-plugins","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/742"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=742"}],"version-history":[{"count":18,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/742\/revisions"}],"predecessor-version":[{"id":20983,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/742\/revisions\/20983"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9295"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}