Regional Nagios Server Setup

by Mike on March 11, 2010

in Nagios

The major goal of the  regional server is to distribute the results of all service checks to the central server.  The regional Nagios machines must use OCSP and OCHP in order to send the proper updates to the central server.

Part One: Passive Checks Course
Part Two: Central Server
Part Three: Regional Server

Join our upcoming Nagios Training Class and start taking lessons from a Nagios instructor.

Nagios Regional Server Setup Training

The blue represents the regional server so that it is transferring the information that it collects from the servers, routers and switches it is monitoring to the central Nagios server.  The same settings for NSCA that you did for passive checks will have to be set up for this server and you will need to use the same password and encryption scheme as on the central server.  See that link as it has not been repeated here.

The default nagios.cfg  has these settings.
obsess_over_services=0
#ocsp_command=somecommand
obsess_over_hosts=0
#ochp_command=somecommand

Change the nagios.cfg settings to those below.  The timeout prevents your Nagios server from spending too much time on one command.
obsess_over_services=1
ocsp_command=service_check
ocsp_timeout=5

obsess_over_hosts=1
ochp_command=host_check
ohcp_timeout=5

You will need to create two scripts in the /usr/lib/nagios/plugins/eventhandlers/distributed-monitoring directory.  This script is key to transferring the  proper information to your central server.

#!/bin/bash
# Service Check

CMD=”/usr/sbin/send_nsca”
CFG=”/etc/nagios/send_nsca.cfg”
HOST=$1
SRV=$2
RESULT=$3
OUTPUT=$4

/bin/echo -e  “$HOST\t$SRV\t$RESULT\t$OUTPUT\n” | $CMD -H nagios -c $CFG

nagios is = to your central Nagios server

#!/bin/bash
# Host Check

CMD=”/usr/sbin/send_nsca”
CFG=”/etc/nagios/send_nsca.cfg”
HOST=$1
RESULT=$2
OUTPUT=$3

/bin/echo -e  “$HOST\t$RESULT\t$OUTPUT\n” | $CMD -H nagios -c $CFG

chmod 755 service_check
chmod 755 host_check

Create a file called misccommands.cfg in the /etc/nagios/objects directory so you can add the new commands.

define command{
command_name   service_check
command_line   $USER1$/eventhandlers/distributed-monitoring/service_check $HOSTNAME$ ‘$SERVICEDEC$’ $SERVICESTATEID$ ‘$SERVICEOUTPUT$’

define command{
command_name   host_check
command_line   $USER1$/eventhandlers/distributed-monitoring/host_check $HOSTNAME$ $SERVICESTATEID$ ‘$SERVICEOUTPUT$’

Be sure to add this line to your nagios.cfg file.

cfg_file=/etc/nagios/objects/misccommands.cfg

Previous post:

Next post: