Quick and easy setup of and connection to NRPE on Ubuntu

About NRPE

NRPE (Nagios Remote Plugin Executor) is a useful tool that allows you to execute scripts on remote servers and return the output for ingestion by some form of monitoring software.


We currently have our own instance of Icinga running to monitor our servers and have recently started to offer access to it for our clients.

The majority of our servers (and our clients servers if we set them up) use one variant or another of Ubuntu. This means we can very quickly get our servers connected to a Nagios/Icinga instance.

First things first we need to install the nrpe server and all the associated plugins

Next we need to edit the main nrpe config file to be found @ /etc/nagios/nrpe.cfg. What your looking for is the lines

You will want to change this to the IP of your Nagios/Icinga instance and set the dont_blame_nrpe value to 1. Feel free to take a look round the rest of the file. Its all quite interesting and generally will documented. Be careful what you change though in case something breaks.

You will also want to look for some lines that are refererd to as “COMMAND DEFINITIONS” and look something like this

You can go ahead and comment these out as we will be adding our own definitions shortly. The main reason for removing these is that we will be configuring some specific scripts for our own use later that allow you to configure your requirements and thereshold from within your Nagios/Icinga config.

Configuration of Monitoring Server

Once this is complete you can now configure a new “check command” for use with your nagios/icinga server.

Here you can see that we have set up 2 different check commands. The first is a simple command requiring only one argument of $ARG1$ which would be the name of the command we want to run on the remote server. The second command is almost identical except for the fact it takes a second argument which allows you to input a series of “arguments” to be passed to the command on your remote server. each argument should be separated by a space.

Now that you have these you can then configure your hosts and services to make use of it. I would recommend having a trawl through the Nagios/Icinga sites & documentation to find out how to create a config that suits you.

Configuration of Remote Server

Now that we have our monitoring server ready its time to add the command we want to run to the remote server.

To do this your /etc/nagios/nrpe.cfg shoudl hopefully have a line in it that looks like

if it doesn’t have a line like that then add it and edit the /etc/nagios/nrpe_local.cfg file to look a little like this

These are a few simple commands that I tend to use most often. These translate to your “check_nrpe” commands like so

  • $ARG1$ = everything inside the square brackets [ ]
  • $ARG2$ = each of the $ARG?$ keys as a single string separated by a space

Once that’s done you should be able restart your nrpe server with /etc/init.d/nagios-nrpe-server restart

It really is that simple. Do bear in mind that because you can pass arbitrary arguments into nrpe this was you could leave yourself vulnerable to a bit of maliciousness so its a good idea to make sure your firewall restricts port 5666 (the default port) to IPs you trust.

Published by

Matt Cockayne

Matt is both a PHP Developer and Scout Leader. Having tried his hand a few different careers he finds that he is happiest working with code as the Technical Lead at Magma Digital. As a framework contributor and serial tinkerer Matt has spent a long time working on being the best PHP Developer he can be. As a Scout Leader he spends a lot of his time devoted to teaching valuable life skills to kids aged 7-18. He is a firm believer that being a Good Scout and Great Developer go hand in hand.

2 thoughts on “Quick and easy setup of and connection to NRPE on Ubuntu”

    1. @Jeremiah:

      You can install some Nagios plugins which come with a series of commands:

      $ apt-get install nagios-plugins nagios-plugins-basic nagios-plugins-standard

      I think these typically install in /etc/nagios-plugins/conf

Leave a Reply