Tuesday, September 1, 2015

Setup Centos as Nagios clients

Centos Linux servers can be monitored by Nagios remotely. This typically provides information of ping response, services running and system information.

The setup is fairly straight forward assuming Nagios server IP is 10.10.2.1 and uses port 5666.

Step 1: Install Nagios plugins and NRPE.

Read the NRPE documentation.
Login to the nagios host, e.g. 10.10.2.2
# yum install -y nagios-plugins-all nrpe net-snmp

Edit /etc/nagios/nrpe.cfg with these 2 values

server_address=127.0.0.1
or the nagios IP

allowed_hosts=10.10.2.1
or the nagios IP

Example to enable monitoring of http is to have this line;
command[check_http]=/usr/lib64/nagios/plugins/check_http -I 10.10.2.2 -w 5 -c 10

Step 2: Start NRPE

# service nrpe start
# chkconfig nrpe on

Test with
 /usr/lib64/nagios/plugins/check_nrpe -H 10.10.2.2 -c check_load

Step 3: Allow monitoring through firewall

E.g. if using IPTABLES, make it as a rule at the top
# iptables -I INPUT 2 -p tcp -m tcp --dport 5666 -j ACCEPT
# iptables -L |grep 5666
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:5666

# service iptables save

Step 4: Configure Nagios server

Enable the services in the Nagios server, in this example 10.10.2.1
# vi /etc/nagios/servers/server1.cfg

define service{
use generic-service,graphed-service
host_name server1
service_description Http
check_command check_nrpe!check_http!-w 5 -c 10
}


Post installation

Check the service is running
# netstat -anlp |grep nrpe
tcp        0      0 10.240.1.14:5666            0.0.0.0:*                   LISTEN      12467/nrpe
unix  2      [ ]         DGRAM                    14250318 12467/nrpe

From the nagios server, test with 
/usr/lib64/nagios/plugins/check_nrpe -H 10.10.2.2

this should return the NRPE version.

/usr/lib64/nagios/plugins/check_nrpe -H 10.10.2.2 -c check_http

this should return the http check at the host.


Self reminder: TODO check_postgres source github

No comments:

Blog Archive