Page 2 of 2
Re: Alerting Utilizing NSCA from Core to XI
Posted: Wed Mar 26, 2014 9:03 am
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
Re: Alerting Utilizing NSCA from Core to XI
Posted: Wed Mar 26, 2014 2:20 pm
by scottwilkerson
I'm sorry, didn't notice that was on the customer only forum, I'll post it below for completeness
Re: Alerting Utilizing NSCA from Core to XI
Posted: Wed Mar 26, 2014 2:20 pm
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
Re: Alerting Utilizing NSCA from Core to XI
Posted: Thu Mar 27, 2014 8:05 am
by dsydnor
I will give this a try.
Thanks!
Re: Alerting Utilizing NSCA from Core to XI
Posted: Thu Mar 27, 2014 9:14 am
by tmcdonald
Let us know how this works for you