Monday, August 29, 2011

How To Install Nagios NRPE Plugin

Concepts of Installation :

1. Download the source file for Nagios plugin + nrpe plugin on host and client.
2. Install the source files.
4. Add client to the host.
3. Config the sensor on host and client.

1. Installation on Client

1.1 Nagios Plugin

Download the source code tarball of the Nagios plugins (visit http://www.nagios.org/download/ for links to the latest versions).

At the time of writing, the latest stable version of the Nagios plugins was 1.4.6.

wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.6.tar.gz

Extract the Nagios plugins source code tarball.

tar xzf nagios-plugins-1.4.6.tar.gz

cd nagios-plugins-1.4.6

Compile and install the plugins.

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install


The permissions on the plugin directory and the plugins will need to be fixed at this point, so run the following commands.

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


1.2 NRPE Plugin

Download the source code tarball of the NRPE addon (visit http://www.nagios.org/download/ for links to the latest versions).

** At the time of writing, the latest version of NRPE was 2.8.

wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-2.8.tar.gz

Extract the NRPE source code tarball.

tar xzf nrpe-2.8.tar.gz

cd nrpe-2.8

Compile the NRPE addon.

./configure
make all


** Install the NRPE plugin (for testing), daemon, and sample daemon config file.

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

Install the NRPE daemon as a service under xinetd.

make install-xinetd

Edit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the only_from directive.

** only_from = 127.0.0.1

Add the following entry for the NRPE daemon to the /etc/services file.

nrpe 5666/tcp # NRPE

Restart the xinetd service.

service xinetd restart

Test the NRPE daemon locally :

** Its time to see if things are working properly...
** Make sure the nrpe daemon is running under xinetd.

netstat -at | grep nrpe

The output out this command should show something like this:

tcp 0 0 *:nrpe *:* LISTEN

** If it does, great! If it doesn't, make sure of the following:

- You added the nrpe entry to your /etc/services file
- The only_from directive in the /etc/xinetd.d/nrpe file contains an entry for "127.0.0.1"
- xinetd is installed and started
- Check the system log files for references about xinetd or nrpe and fix any problems that are reported

** Next, check to make sure the NRPE daemon is functioning properly. To do this, run the check_nrpe plugin that was installed for testing purposes.

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

** You should get a string back that tells you what version of NRPE is installed, like this:

NRPE v2.8

Open firewall rules :

Make sure that the local firewall on the machine will allow the NRPE daemon to be accessed from remote servers.

To do this, run the following iptables command :

** Note that the RH-Firewall-1-INPUT chain name is Fedora specific, so it will be different on other Linux distributions.

iptables -I RH-Firewall-1-INPUT -p tcp -m tcp –dport 5666 -j ACCEPT

Save the new iptables rule so it will survive machine reboots.

service iptables save


Customize NRPE Plugin :

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

The commands should be synchronized with Nagios host configuration for client.


How To Clear SSH Session On Linux

If you found that there are too many idle users in your servers and you want to kill them? You can do that by this simple command :

kill -9 `ps aux|grep sshd|awk '{print $2}'`

This command will simply kill all the process based on "process id" on run by all "sshd connections".