Thursday, 26 May 2011

How to install NRPE on linux

Hi All,

Ok, ok. Avoiding the fact that this is the first post and monitoring is not mentioned in the description, this is how I install the NRPE agent for Nagios on Linux boxes.

Logon to the box you want to monitor.

Create a directory somewhere called NRPE and go in it.

mkdir NRPE
cd NRPE

Download the following packages (google them I'll never keep up with versioning):
http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.6.tar.gz
http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-2.8.tar.gz

As you can see you can get the latest versions from sourceforge.
Do all the following as root (su -)

Make a user called nagios and give it a password

/usr/sbin/useradd nagios
passwd nagios

First we install the plugins.

tar xzf nagios-plugins-1.4.6.tar.gz
cd nagios-plugins-1.4.6.tar.gz
./configure
make
make install

That'll do it. Now run these commands

chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

What those 2 lines do is change the owner of /usr/local/nagios and everything under /usr/local/nagios/libexec to the nagios user you created a minute ago. The other directories will still be owned by root.

Now you need to install the NRPE bit itself. Go back to your NRPE directory you created earlier (if you are still with me type cd ..).

Type in:

tar xzf nrpe-2.8.tar.gz

Now it's a little more complicated than last time. Make sure you have openssl and all dependancies installed (yum install openssl or apt-get install openssl, or whatever for your distro).

Then type these commands in:

cd nrpe-2.8.tar.gz
./configure
make all

now run these:

make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd

Thats it installed. Now for the configuration. Don't worry, by this time its taken a maximum of 10 mins from start to finish. It looks more complex than it is.

Config time:

type this in:

vi /etc/xinetd.d/nrpe

Press the insert button on your keyboard.
Go down to the "only_from" line and add your Nagios server IP onto the end of the line.
Then press the escape key then type :wq

This is to grant your nagios server permission to connect to the NRPE daemon.
Next we want to give the port number a service alias so....

vi /etc/services

Press your insert button and add an entry it can go anywhere, but be sensible. It must look like this:
nrpe 5666/tcp # NRPE

press escape then type :wq

For those of you with firewalls, this tells you that the daemon is running on port 5666, so needs to be open for connections from your Nagios box, to this server, on 5666.

Now restart xinetd service like this:

service xinetd restart

Test it's listening by typing this:
netstat -aunt | grep nrpe

To check that NRPE is receiving commands type this:

/usr/local/nagios/libexec/check_nrpe -H localhost

If you get a version number back you are good to go.

By default you get a bunch of checks installed by default. To change the values modify this file:

/usr/local/nagios/etc/nrpe.cfg

Scroll down to the bottom and you'll see some lines prefixed with the word command. You can change the -w and -c options. You can even create your own scripts in perl and create your own commands, but more on that later.

Thanks for reading,

Trev

No comments:

Post a Comment