Configure Nagios NRPE to Allow Monitoring Host Server with No Login SSH

NRPE (Nagios Remote Plugin Executor) allows you to remotely execute Nagios plugins on other Linux/Unix machines. This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). NRPE can also communicate with some of the Windows agent addons, so you can execute scripts and check metrics on remote Windows machines as well. NRPE is hands down, the best remote plugin executor for Nagios.

The scheme of the NRPE Daemon like here

Schema Daemon NRPE
Figure 1. Schema Daemon NRPE

In this tutorial we will create topology like in below and you will learn how to install NRPE in host monitoring server.

Topology NRPE
Figure 2. Topology NRPE

Step 1. Install NRPE in Client Nagios

Install NRPE from ports

$ cd /usr/ports/net-mgmt/nrpe/
$ make config
$ make install clean
uncheck [ ] SSL Enable SSL Support
uncheck [ ] ARGS Enable command argument processing

Make nrpe is start on booting

$ echo 'nrpe2_enable="YES"' >> /etc/rc.conf

Next, move sample config nagios nrpe in /usr/local/etc/ to nrpe.cfg

Open file nrpe.cfg and edit this line

log_facility=daemon
pid_file=/var/spool/nagios/nrpe2.pid
server_port=51666 # changing from default to upper value
nrpe_user=nagios
nrpe_group=nagios
allowed_hosts=127.0.0.1, 203.6.xx.xx # ip address of server nagios 
dont_blame_nrpe=0 # don't allow to receive command line arguments from nagios
debug=0
command_timeout=60
connection_timeout=300
# commands definitions
command[check_users]=/usr/local/libexec/nagios/check_users -w 6 -c 10
command[check_load]=/usr/local/libexec/nagios/check_load -w 15,10,5 -c 30,25,20
command[check_root]=/usr/local/libexec/nagios/check_disk -w 20% -c 10% -p /
command[check_var]=/usr/local/libexec/nagios/check_disk -w 20% -c 10% -p /var
command[check_tmp]=/usr/local/libexec/nagios/check_disk -w 20% -c 10% -p /tmp
command[check_usr]=/usr/local/libexec/nagios/check_disk -w 20% -c 10% -p /usr
command[check_zombie_procs]=/usr/local/libexec/nagios/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/libexec/nagios/check_procs -w 150 -c 200
command[check_memory]=/usr/local/libexec/nagios/check_memory -w 85 -c 95
command[check_swap]=/usr/local/libexec/nagios/check_swap -w 15% -c 7%

Add this  in end of line /etc/services

nrpe2           5666/tcp   #NRPE

Add rule of nagios nrpe , open file /etc/hosts.allow and add this line

nrpe : 203.6.xx.xx/255.255.255.0 : allow

Next, start process nrpe with type command

$ /usr/local/etc/rc.d/nrpe2 start

Check NRPE is running with type command

$ /usr/local/libexec/nagios/check_nrpe2 -H localhost
NRPE v2.15

Step 2. Configuration in Nagios Server

Open file command.cfg in directory /usr/local/etc/nagios/objects/

Add this scripts

define command {
 command_name check_nrpe
 command_line $USER1$/check_nrpe2 -H $HOSTADDRESS$ -n -c $ARG1$
 register 1
}

Check from Server Nagios, clients nagios nrpe can connecting or not with type command

$ /usr/local/libexec/nagios/check_nrpe2 -H 103.xx.xx.xx -n -c check_users
CHECK_NRPE: Socket timeout after 10 seconds.
$ /usr/local/libexec/nagios/check_nrpe2 -H 103.xx.xx.xx -n -c check_users
USERS OK - 1 users currently logged in |users=1;5;10;0
$ /usr/local/libexec/nagios/check_nrpe2 -H 103.xx.xx.xx -n -c check_root
DISK OK - free space: / 17888 MB (70% inode=90%);| /=7657MB;22213;24990;0;27767
$ /usr/local/libexec/nagios/check_nrpe2 -H 103.xx.xx.xx -n -c check_usr
DISK OK - free space: / 17888 MB (70% inode=90%);| /=7657MB;22213;24990;0;27767
$ /usr/local/libexec/nagios/check_nrpe2 -H 103.xx.xx.xx -n -c check_zombie_procs
PROCS OK: 0 processes with STATE = Z | procs=0;5;10;0;

If all configuration finish, we must create remote host monitoring

Create file remote.cfg in directory host, and add this line

define host {
 use remote-host
 host_name rem-server-224-52
 max_check_attempts 6
 check_command check_http
 address 103.xx.xx.xx
 register 1
 }

Next, create service command

define service {
 use root-service,graphed
 host_name rem-server-224-52
 service_description CPU Load
 check_command check_nrpe!check_load
 register 1 
}
define service {
 use root-service,graphed
 host_name rem-server-224-52
 service_description Current Users
 check_command check_nrpe!check_users
}
define service {
 use root-service,graphed
 host_name rem-server-224-52
 service_description HDD Root
 check_command check_nrpe!check_root
}
define service {
 use root-service,graphed
 host_name rem-server-224-52
 service_description Total Process
 check_command check_nrpe!check_total_procs
}
define service {
 use root-service,graphed
 host_name rem-server-224-52
 service_description Zombie Procs
 check_command check_nrpe!check_zombie_procs
}

After that, check configuration of nagios and restart service nagios

$ /usr/loca/etc/rc.d/nagios restart

You can look in web interface, client server monitoring can add and show that services

Remote Host
Figure 3. Remote Host

Source : http://blog.kupchanko.cv.uahttp://www.jordansphere.co.uk/ and http://beginlinux.com/

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s