Set up NRPE (v2.13) with xinetd in ubuntu server 14.04

Update softwar repo, install gcc, create temporary installation dirs, create nagios user, install xinetd, download and compile NRPE…

apt-get update ; apt-get install gcc -y ; mkdir /tmp/download ; useradd nagios -s /bin/false ; mkdir /usr/local/nagios ; chown nagios:nagios /usr/local/nagios ; cd /tmp/download ; apt-get install xinetd -y ; wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz ; wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz ; tar zxvf nrpe-2.13.tar.gz ; cd nrpe-2.13 ; ./configure --disable-ssl --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --libexecdir=/usr/local/nagios/libexec/ --bindir=/usr/local/nagios/bin/ --prefix=/usr/local/nagios ; make all ; make install-plugin ; make install-daemon ; make install-daemon-config ; make install-xinetd ; update-rc.d xinetd defaults

Edit /etc/xinetd.d/nrpe

nano -w /etc/xinetd.d/nrpe

add ip address of the monitoring nagios server

only_from = 127.0.0.1 <ip_address_of_monitoring_server>

Edit /etc/services

nano -w /etc/services

Make sure this line ‘nrpe 5666/tcp # NRPE‘ is on the file, or add it in the end, then save, exit and restart xinetd:

service xinetd restart
netstat -at | grep nrpe

Install nagios-plugins

cd ../ ; tar zxvf nagios-plugins-2.1.1.tar.gz ; cd nagios-plugins-2.1.1 ; ./configure --with-nagios-user=nagios --with-nagios-group=nagios ; make ; make install

Config file of NRPE (nrpe.cfg) is located in /usr/local/nagios/etc/nrpe.cfg
You can add different commands in there

Exit and restart xinetd:

service restart xinetd

In case you need routing to the monitoring host:

route add -host <ip_of_monitoring_server> gw <routing_ip> dev eth0

Or do it manually by editing /etc/network/interfaces and add this in the end:

# Static routes

up route add -host <ip_of_monitoring_server> gw <routing_ip> dev eth0

 

Install memory check nagios plugin:

Download this file check_mem.pl and place it in /usr/local/nagios/libexec
Path should look like: /usr/local/nagios/libexec/check_mem.pl

cd /usr/local/nagios/libexec/ ; chown nagios:nagios check_mem.pl ; chmod 755 ./check_mem.pl

Edit NRPE config file /usr/local/nagios/etc/nrpe.cfg and add the command:

command[check_mem]=/usr/local/nagios/libexec//check_mem.pl -w 5 -c 2 -f -C

Exit and restart xinetd:

service xinetd restart
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s