How to Monitor Hosts using Nagios NRPE on Debian 9. In our recent article we have shown how to install nagios core on Debian 9 to monitor some remote hostss services. To do that you will need to install Nagios NRPE daemon and plugins on the remote hosts. It is a package that will be installed on all the remote hosts which need to be monitored. NRPE Nagios Remote Plugin Executor is an addon which allows you to remotely execute Nagios plugins on remote Linux machines. It allows you to monitor remote machine metrics disk usage, CPU load, etc. It can also communicate with some Windows agent addons like NSClient, so you can execute scripts and check metrics on remote Windows hosts as well. In this article, I will explain to you how you can monitor your Linux and Windows hosts servers with Nagios. How does NRPE work NRPE is a monitoring agent and protocol that is often used to monitor remote hosts with Nagios. NRPE works with a client checknrpe plugin that runs on the Nagios servera daemon that runs on the remote server, processes requests from the client, and returns status information. We can summarize the process by the scheme below. Nagios Server checknrpe Remote host NRPE deamon servicetocheck. Nagios Server checknrpe lt Remote host NRPE deamon lt servicetocheck. When Nagios needs to monitor a resource of service from a remote machine Nagios will execute the checknrpe plugin and tell it what services need to be checked. The checknrpe plugin contacts the NRPE daemon on the remote host. The NRPE daemon runs the appropriate Nagios plugin to check the service or resource. The results from the service check are passed from the NRPE daemon back to the checknrpe plugin, which then returns the check results to the Nagios process. NRPE can be configured to only accept connections from a specific IP address. You can just tell it what commands to run through the connection. Only commands that the local host has configured will be allowed and you can determine if arguments will be sent by Nagios. Add a Linux host on nagios server. In order to use the NRPE add on, youll need to perform some tasks on both the Nagios server and the remote Linux host where the NRPE daemon is installed on. In our, case the remote Linux host is a Debian 9 server. I will show the specifics points of the procedure for Centos and Ubuntu servers. Configure the remote Linux host. We need to install the nagios and NRPE plugins on the remote server to monitor. Installation Instructions. Before installing CleanUp please take the time to read the following Please make a backup of your hard disk before running CleanUp for. Monitoring VMware ESX System Health and Hardware using Nagios. Running a reliable hosting infrastructure requires you have tools and processes in place to catch. Install the nagios plugin. We need first to install pre requisites apt install y autoconf gcc libc. On Centos 7 install the pre requisites as below yum install y gcc glibc glibc common make gettext automake autoconf wget openssl devel net snmp net snmp utils epel release perl Net SNMPNow we will create our working directory into opt directory where we will download the plugins mkdir optnagios cd optnagios wget no check certificate O nagios plugins. Now we will compile and install the plugins. toolssetup. configure make make install. Install the nrpe plugin. Now we can download the lastest version of nrpe which is nrpe plugin 3. I am writing this article. cd optnagios wget no check certificate O nrpe. Nagios. Enterprisesnrpearchivenrpe 3. Now we will compile it. configure enable command args make all. For Ubuntu the compilation command is. configure enable command args with ssl libusrlibx. We will need to create nagios user and group on the remote Linux host too make install groups users. We will install the binary files, the NRPE daemon, the checknrpe plugin and the config files make install make install config. Now we will map the nrpe port number 5. Nagios services etcservices echo nrpe 5. We will install services and make sure to start nrpe when the system startup make install init systemctl enable nrpe. Configure the firewall. It is important now to configure the firewall to accept all nrpe communication iptables I INPUT p tcp destination port 5. ACCEPTWe will install iptables persistent which takes over the automatic loading of the saved iptables rules. To do this, the rules must be saved in the file etciptablesrules. Make sure to answer yes to save existing rules. Normally you can use iptables save command to save iptables new rules. On Centos 7, configure the firewall as below firewall cmd zonepublic add port5. Authorize the nagios server to communicate with the host. After installing nrpe plugin, we need to configure all the host allowed to communicate with the nrpe plugin on the Linux host. It means that we shall indicate the nagios server information IP address, etc to be reached. The file usrlocalnagiosetcnrpe. Find the directive allowedhosts and add the private IP address of your Nagios serverallowedhosts1. Find the directive dontblamenrpe to determine whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed. Start and test nrpe service. To start nrpe service use the command below systemctl start nrpe. Now to see if things are working properly, we need to make sure that nrpe daemon is first running netstat at egrep nrpe5. LISTEN. tcp. 6 0 0 nrpe LISTENNow we can test if nrpe works locally by running the checknrpe plugin which was installed usrlocalnagioslibexecchecknrpe H localhost. NRPE v. 3. 2. 0. You should have the output above which indicates that nrpe plugin works perfectly on the Linux host. The NRPE configuration file that got installed contains several commands definitions which we can be used to monitor our remote host. Now we need now to configure the nagios serverb Configure the nagios server to detect the remote host. This article assumes that you have already installed and configured the Nagios server on Debian 9. It means that you will now configure it to detect and add our remote Linux host. If you have not configured it yet, please follow this article. On the nagios server, we will need to install nrpe plugin too and create a configuration file for the Linux host. Install nrpe plugin. The procedure is exactly the same as on the Linux host but dont forget that on the nagios server we already have a nagios user and group so we can skip that step. We will move to our nagios working directory cd optnagios wget no check certificate O nrpe. Nagios. Enterprisesnrpearchivenrpe 3. Now we will compile it tar xzf nrpe. We will install binaries and configuration files make install make install config. We will need to add nrpe service too echo etcservices echo Nagios services etcservices echo nrpe 5. We will install services and make sure to start nrpe at the system startup make install init systemctl enable nrpe. Configure the firewall and nrpe service. We will also configure the firewall to allow the nrpe communication with all the hosts. iptables I INPUT p tcp destination port 5. ACCEPT systemctl start nrpe. Test communication with the remote Linux host nrpe daemon. We need to make sure the checknrpe plugin can talk to the NRPE daemon on the remote host. We will use the checknrpe plugin with the IP address of the remote host as you can see below usrlocalnagioslibexecchecknrpe H 1. NRPE v. 3. 0. Now we will use a command definition to try to monitor a service check cpu load on the remote Linux. usrlocalnagioslibexecchecknrpe H 1. CRITICAL load average 0. You can see that we have a response of the remote Linux to monitor. It shows that our plugin works perfectly on the remote host and the communication is good. Define a new Linux Host and services on the nagios server. Nagios contains by default some object definitions into the usrlocalnagiosetcobjects directory on the nagios server which represents each type of host that you can need to monitor. ls usrlocalnagiosetcobjects. We will first create a folder in which we will save all the remote host configuration files that Nagios server must monitor. mkdir usrlocalnagiosetcobjectsservers. Nagios has a template file templates. These definitions will be helpful when we will create each remote host file definition. By default, Nagios monitor the server where it is installed through the localhost.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2017
Categories |