Nagios - Monitoring remote Linux host Using NSClient++

From open-voip.org

Jump to: navigation, search

Now will will monitor a remote linux server (192.168.0.149 in this example). This server is with asterisk installed, so we will monitor the sip in the next lesson.the asterisk installation described here :Asterisk Install.

Contents

Configure the Remote linux host

we will start with the remote host, install the following packages:

 yum install nrpe
 yum install nagios-plugins-nrpe

create a nagios user and set a password, we will choose "nagios" as password:

 useradd nagios
 passwd nagios

allow the nagios server to sample this host (192.168.0.148 is the nagios IP)

 vi /etc/nagios/nrpe.cfg 

unremark (remove the #) and add the nagios server IP:

 allowed_hosts=127.0.0.1,192.168.0.148

save and exit.

Now make the NRPE to start after reboot:

 chkconfig --level 345 nrpe on

Verify installation (make sure no iptables issues and nrpe is running):

  /usr/lib/nagios/plugins/check_nrpe -H localhost

Configure the Nagios to monitor the Linux server

install the following:

 yum install nrpe*
 yum install nagios-plugins-nrpe

Test the remote linux host (0.149) from the nagios server (0.148) :

 /usr/lib/nagios/plugins/check_nrpe -H 192.168.0.149
 NRPE v2.7

Create host and service definition for remotehost

 vi /usr/local/nagios/etc/objects/localhosts.cfg 

host definition sample, add the following:

 define host{
       use                     linux-server            ; Name of host template to use
                                                       ; This host definition will inherit all variables that are defined
                                                       ; in (or inherited by) the linux-server host template definition.
       host_name               sipp_asterisk
       alias                   sipp_asterisk
       address                 192.168.0.149
       }

and add to the host group members the "sipp_asterisk" as follow:

 define hostgroup{
       hostgroup_name  linux-servers ; The name of the hostgroup
       alias           Linux Servers ; Long name of the group
       members         localhost,sipp_asterisk     ; Comma separated list of hosts that belong to this group
       }

Add services to Monitor

we will add ping check and disk space check:

 define service{
       use                             local-service         ; Name of service template to use
       host_name                       sipp_asterisk
       service_description             PING
       check_command                   check_ping!100.0,20%!500.0,60%
       }
 # Define a service to check the disk space of the root partition
 # on the local machine.  Warning if < 20% free, critical if
 # < 10% free space on partition.
 define service{
       use                             local-service         ; Name of service template to use
       host_name                       sipp_asterisk
       service_description             Root Partition
       check_command                   check_local_disk!20%!10%!/
       }

restart nagios

 /etc/init.d/nagios restart
Personal tools