Enabling NRPE linux monitoring

If you have an working Nagios Core monitoring server and some Linux machines (physical or virtual) you might want or even need to monitor their state. Nagios is a cool and free solution that makes this quite simple.

After you have deployed Nagios Core 4.0.x and up as a monitoring host you need to install monitoring daemon on Linux hosts. I have managed to monitor multiple Linux hosts with Nagios Core. All my Linux hosts run Debian or Ubuntu and this quick guide is based on Debian (wheezy).

Let’s start 🙂

1. Login to the Linux host you want to monitor, change to root:

user@nagios:~$ sudo -s

[sudo] password for user:

2. Install necessary packages from the Internet:

$ apt-get install nagios-nrpe-server nagios-plugins

3. Edit the nrpe.cfg config file located in /etc/nagios/nrpe.cfg
by editing and uncommenting line

allowed_hosts=127.0.0.1

and changing 127.0.0.1 to your Nagios Core monitoring server IP Address
4. Restart nrpe daemon by issuing a command:

$ service nagios-nrpe-server restart

After above steps your host is ready to be monitored by your Nagios Core server.
Now we have to add the new host to the server config:
1. Login to the Nagios Core server, change to root:

user@nagios:~$ sudo -s[sudo] password for user:

2. Navigate to where nagios is installed, in my config it is:

/usr/local/nagios/

3. cd into /etc/ folder
If you haven’t add any Linux servers yet, and I assume you heaven’t since you are reading this guide
4. Edit your nagios.cfg file. Add the following lines

# Definitions for Linux hosts
cfg_file=/usr/local/nagios/etc/objects/linux.cfg

just under:

# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

If you have problems using VI editor, here’s a useful command library
5. Save changes, exit VI
6. Navigate to /usr/local/nagios/etc/objects#
and copy localhost.cfg into linux.cfg
7. Edit linux.cfg file and change all instances of localhost to hostname of which you want to monitor, and change 127.0.0.1 to the IP Address of monitored host.
You can add alias or whatever definitions you like. Nice definition list is located here
If you have linux-servers group created, and I assume you do since it’s declared in localhost.cfg you may want to add monitored hostname to the localhost.cfg in the following line:

define hostgroup{
hostgroup_name  linux-servers ; The name of the hostgroup
alias      Linux Servers; Long name of the group
members    localhost,YOUR_MONITORED_HOST_SHORTNAME*
}

*This short name is defined in linux.cfg define host section next to host_name, for example:

host_name    glpi

8. Save all changes, exit VI
9. Restart Nagios and Apache2 service by running:

service nagios restart
service apache2 restart

That would be all. Your Nagios Core server should now be able to view state of your host.

By |2016-12-22T21:35:10+00:00July 11th, 2014|Linux|1 Comment

Share With A Friend, Choose Your Way!

About the Author:

I am passionate about Systems Administration. I like to face new challenges and test new environments.Windows and Linux Debian boxes (both physical and virtual) are my favourites. I like solving problems related to Windows Server roles and services as well as Linux but some distributions in particular. I'm not considering myself as Linux master but surely, I always do my best to fit the needs. On the other hand I consider myself as a Windows Server Professional and in terms of WS and Windows Desktops I always follow best practices, good advices and opinions from other admins.

One Comment

  1. […] suggesting a possible solution. Pingback: Piper(). for example the story about “Battlefield 1” is in the RSS but not in the opera newsfeed. I guess it was fate that I found […]

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.