Alerting Utilizing NSCA from Core to XI

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
dsydnor
Posts: 14
Joined: Thu Feb 06, 2014 1:35 pm

Re: Alerting Utilizing NSCA from Core to XI

Post by dsydnor »

Hello Scott,

I do not have access to view that post.

viewtopic.php?f=16&t=6659&p=30341&hilit=send_nsca#p30341

Please advise.

--Darryn
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Alerting Utilizing NSCA from Core to XI

Post by scottwilkerson »

I'm sorry, didn't notice that was on the customer only forum, I'll post it below for completeness
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Alerting Utilizing NSCA from Core to XI

Post by scottwilkerson »

Here's an example using NSCA

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

The default nagios.cfg has these settings.

Code: Select all

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.

Code: Select all

obsess_over_services=1
ocsp_command=service_check
ocsp_timeout=5
obsess_over_hosts=1
ochp_command=host_check
ochp_timeout=5
You will need to create two scripts in the /usr/local/nagios/libexec/eventhandlers (RPM repository
/usr/lib/nagios/plugins/eventhandlers/) directory.

service_check

Code: Select all

#!/bin/bash
# Service Check
cmd="/usr/local/nagios/bin/send_nsca"
cfg="/usr/local/nagios/etc/send_nsca.cfg"
host=$1
srv=$2
result=$3
output=$4
/bin/echo -e
"$host\t$srv\t$result\t$output\n" | $cmd -h <CENTRAL_NAGIOS_IP> -c $cfg
host_check

Code: Select all

#!/bin/bash
# Host Check
cmd="/usr/local/nagios/bin/send_nsca"
cfg="/usr/local/nagios/etc/send_nsca.cfg"
host=$1
result=$2
output=$3
/bin/echo -e
"$host\t$result\t$output\n" | $cmd -h <CENTRAL_NAGIOS_IP> -c $cfg

Code: Select all

chmod 755 service_check
chmod 755 host_check
chown nagios:nagios *
Create a file called misccommands.cfg in the /usr/local/nagios/etc/objects (RPM repository /etc/nagios/objects)
directory so you can add the new commands.

Code: Select all

define command{
command_name service_check
command_line $USER1$/eventhandlers/service_check $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATEID$ '$SERVICEOUTPUT$'
}
define command{
command_name host_check
command_line $USER1$/eventhandlers/host_check $HOSTNAME$ $SERVICESTATEID$ '$SERVICEOUTPUT$'
}
Be sure to add this line to your nagios.cfg file.

Code: Select all

cfg_file=/usr/local/nagios/etc/objects/misccommands.cfg
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dsydnor
Posts: 14
Joined: Thu Feb 06, 2014 1:35 pm

Re: Alerting Utilizing NSCA from Core to XI

Post by dsydnor »

I will give this a try.

Thanks!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Alerting Utilizing NSCA from Core to XI

Post by tmcdonald »

Let us know how this works for you
Former Nagios employee
Locked