NRPE Handler
NRPE Handler
An event handler designed to handle remote host and service issues via NRPE.
Download nrpe_handler
NAME
nrpe_handler.pl
SYNOPSIS
nrpe_handler.pl [OPTIONS] --cmd=DOWN:hostname:command:arg1,arg2,arg3 $HOSTSTATE$ $HOSTSTATETYPE$ $HOSTATTEMPT$ $HOSTDOWNTIME$
nrpe_handler.pl [OPTIONS] --cmd=CRITICAL:hostname:command:arg1,arg2,arg3 $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $SERVICEDOWNTIME$
DESCRIPTION
Nrpe_handler is a Nagios event handler designed to execute programs via NRPE.
It is keyed around host and service state to ensure maximum flexiblity handling
host and service problems.
There are no requirements for installation on the Nagios host, other than
Sys::Syslog if that is desired. Edge machines will need a working NRPE daemon
running typically on port 5666. This will likely require tweaks of the nrpe.cfg
file and potentially changes to /etc/sudoers if elevated access is required.
See the necessary docs. (hint in sudoers: turn off requiretty)
OPTIONS
- -c, --cmd=STATE:HOST:COMMAND:ARG1,ARG2,ARG3
-
Command definition.
STATE: in what hoststate or servicestate to run the command
HOST: on which host to run the command
COMMAND: command to run via NRPE on the remote host
ARGLIST: optional comma-separated list of arguments to pass to the command
More than one command can be run by issuing multiple --cmd options.
- -d, --debug
-
Print debug info to logs, if logging.
- -l, --log=LOGFILE
-
Log messages to given file.
- -s, --syslog
-
Log messages to syslog.
- $STATE$ $STATETYPE$ $ATTEMPT$ $DOWNTIME$
-
Nagios macro variables.
Host handler: hoststate hoststatetype hostattempt hostdowntime.
Service handler: servicestate servicestatetype serviceattempt servicedowntime.
CONFIGURATION
Sample configurations for host and service checks.
Host Handler
Assume we are using machine nagios1 to monitor a host named virt1, a VM running
on blade1. We ultimately want to restart virt1 when it goes down by connecting
to blade1 and issuing the necessary commands.
On nagios1, Nagios config:
define host{
use generic-host
name virt1
check_command check-vm-alive
event_handler restart_vm!blade1!virt1
}
define command{
command_name restart_vm
command_line $USER1$/nrpe_handler.pl --debug --log=/tmp/restart_vm.debug
--cmd=DOWN:$ARG1$:restart_vm:$ARG2$
$HOSTSTATE$ $HOSTSTATETYPE$ $HOSTATTEMPT$ $HOSTDOWNTIME$
}
On blade1, NRPE config:
command[restart_vm]=/usr/lib/nagios/plugins/restart_vm.sh $ARG1$
Service Handler
Assume nagios1 monitors a temperamental LDAP service on ldap1. We want to
restart that service when it goes critical by connecting to ldap1 and issuing
the necessary commands.
On nagios1, Nagios config:
define service{
use generic-service
service_description LDAP Service
host_name ldap1
check_command check_ldap
event_handler fix_slapd!ldap1
}
define command{
command_name fix_slapd
command_line $USER1$/nrpe_handler.pl --syslog
--cmd=CRITICAL:$ARG1$:fix_slapd
$SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $SERVICEDOWNTIME$
}
On ldap1, NRPE config:
command[fix_slapd]=/usr/lib/nagios/plugins/fix_slapd.sh
CHANGES
nrpe_handler 1.00 (20120626)
- Initial release.
|