Friday, July 3, 2015

How to Add Linux Host to Nagios Monitoring Server (RPM based)

Install NRPE on Clients

$ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
(for version 5:
$ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm)
$ sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
(for version 5:
$ sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm)
$ sudo yum -y install nrpe
$ sudo chkconfig nrpe on

Edit /etc/nagios/nrpe.cfg
$ sudo vi /etc/nagios/nrpe.cfg
Make sure to change allowed_hosts to your own values.
In check_disk, make sure your server has the same partition by running df -h 
For example:
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /

sets Warning at 20% free disk space remaining, and Critical alert at 10% free space remaining.

Make sure your server's firewall allows tcp 5666
$ sudo system-config-firewall-tui 
$ service iptables restart
Start nrpe on the client server
$ sudo service nrpe start
ON the monitoring server:
Add Server Configurations on Monitoring Server
echo "cfg_dir=/etc/nagios/servers" >> /etc/nagios/nagios.cfg
mkdir -p /etc/nagios/servers
cd /etc/nagios/servers
touch 192.168.1.94.cfg
vi /etc/nagios/servers/192.168.1.94.cfg
Add the following lines:
define host {
        use                     linux-server
        host_name               192.168.1.94
        alias                   dev
        address                 192.168.1.94
        }

define service {
        use                             generic-service
        host_name                       192.168.1.94
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }

define service {
        use                             generic-service
        host_name                       192.168.1.94
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           0
        }

define service {
        use                             generic-service
        host_name                       192.168.1.94
        service_description             Current Load
        check_command                   check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
        }
set folder permissions correctly and restart Nagios on your Monitoring Server:
chown -R nagios. /etc/nagios
service nagios restart

Popular Posts