Monday 14 March 2016

Monitoring Linux Hosts with NAGIOS and NRPE

We should firstly install the NRPE agent of the server we wish to monitor:

wget http://assets.nagios.com/downloads/nagiosxi/agents/linux-nrpe-agent.tar.gz
tar xzf linux-nrpe*
cd linux-nrpe*
sudo ./fullinstall

** Ensure that your firewall on the client allows port 5666 (TCP/NRPE) and 5667(NSCA) inbound connections from your NAGIOS server **

We will then be prompted to enter the IP address of your NAGIOS monitoring server(s.)

Once installed you will find a set of pre-defined commands in /usr/local/nagios/etc/nrpe.cfg - which (of course) we can add additional checks to if required.

Now the next step is too install the NRPE plugin on the NAGIOS server:

wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar zxvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
make all
make install-daemon
make install-plugin

We should also ensure that the relevent checks we wish to perform are uncommented in the following config on the client:

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

We can now do a quick test of the plugin with:

/usr/local/nagios/bin/nrpe -H 1.2.3.4

We should proceed by creating the relevent definitons for the new linux host and it's services e.g.:

Add the following lines in nagios.conf

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

# Definitions for monitoring Linux hosts
cfg_file=/usr/local/nagios/etc/objects/linux.cfg

and then create the linux.cfg file and add our host and service definitions:

sudo vi /usr/local/nagios/etc/objects/linux.cfg

define host{
        use             linux-server  ; Inherit default values from a template
        host_name       mylinuxserver.domain.com    ; The name we're giving to this host
        alias           My Linux Server    ; A longer name associated with the host
        max_check_attempts 3
        contacts        NAGIOS Alerting
        address         mylinuxserver.domain.com       ; IP address of the host
        }
     
define service{
            use                             generic-service
            host_name                       mylinuxserver.domain.com
            service_description             CPU Load
            check_command                   check_nrpe!check_load
            max_check_attempts              3
            check_interval                  3
            retry_interval                  1
            check_period                    24x7
            notification_interval           30
}

0 comments:

Post a Comment