Nagios Server : Adding Linux hosts for monitoring using NRPE
Last updated on March 12th, 2018 at 09:32 pm
In our earlier tutorials, we installed & configured Nagios Monitoring server & also added Windows host to Nagios Server using NSClient++. In this tutorial, we will learn to add Linux Hosts to Nagios Server with the help of NRPE.
NRPE aka Nagios Remote Plugin Executor, allows us to monitor the local resources of a Linux host on Nagios monitoring server. It needs to be installed on both Linux host & on Nagios server. So let’s start with configuring Linux host first.
(Recommended Read: Easy guide to setup Nagios monitoring using SSH (check_by_ssh))
Configuring Linux Host
Before we begin installtion, we will first install Nagios plugin on host
Installing required packages
Install the following packages to resolve all dependencies required for installing the plugins ,
Download the Nagios Plugins
Next, we will download the Nagios plugins from the following url
Installing & Configuring the plugin
Before installing Nagios plugin, we need to add a user “nagios”
after creating user, goto the folder with plugins. We will now extract the plugins
And now we will compile & install the plugins
Changing the ownership of plugin folder
After the plugins are installed, we will change the ownership of the plugins folders
Downloading & installing NRPE
Now its time we download the plugin, use the link below
then, extract the plugin
next, we compile & install it
Making changes to Config file
Now open config file and add the localhost and IP address of the Nagios Monitoring Server.
& in /etc/services file , add following line & save it
finally, start xinetd
Note:- xinted is installed on most of the Linux distributions by default, but if that is not the case you install it using
yum install xinetd.
Verifying connectivity from Nagios to host
Now that the plugin has been installed, we will verify connectivity of host from nagios server by following on Nagios server
where, 192.168.1.115 is IP address of Linux host which is to be monitored.
Note:- NRPE config file (/usr/local/nagios/etc/nrpe.cfg) has some of the commands already written on it, you can modify them as per your needs & can test them by directly running these on terminal.
Next, we move on to Nagios & configure it to receive updates from Linux host.
Nagios Server configuration
Download & install NRPE
First, we download & install remote plugin on Nagios server , as we did on Linux host
Adding remote Linux host
Create two files named linux_hosts.cfg & linux_services.cfg in folder “/usr/local/nagios/etc/”
then we will edit nagios.cfg & add the following two files in it
Now, we will copy the default templates for hosts & services, present in /usr/local/nagios/etc/objects/ to these files & will edit them as per our need
Firstly , open linux_hosts.cfg & edit it (see screenshot)
then we will add services in linux_services.cfg (see screenshot)
& lastly, we will add NRPE command definition to /usr/local/nagios/etc/objects/commands.cfg
& add the following command definition
Verifying Nagios configuration file
If there are any errors, resolve them & then restart the nagios server for changes to take effect.
Open your web-console, by typing your nagios IP address or FQDN in your browser & enter credentials for nagios. Once inside the web-console, goto services page & you should see that services for your Linux hosts have added here for monitoring .
So, this was our tutorial on how to add Linux hosts to Nagios server for monitoring. If you have any queries or comments, please mention them on the comment box down below.