Page 1 of 2

NSCA ocsp command not executing

Posted: Fri Apr 20, 2012 11:45 am
by mitchsmith
Hi,

I have an XI installation in which I am trying to get a subset of checks to send results to a central nagios instance using NSCA.

In the check settings obsess_over_service is set to on. And the ocsp command is defined. However appears to not execute.

submit_service_check command

Code: Select all

$USER1$/eventhandlers/submit_service_check "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$ | $SERVICEPERFDATA$ [$SERVICECHECKCOMMAND$]]
resources.cfg

Code: Select all

$USER1$=/usr/local/nagios/libexec

nagios.cfg
obsess_over_services is set to 0 as i do not want to submit check results for all just a subset. Is this correct?

Code: Select all

obsess_over_services=0
ocsp_timeout=60
ocsp_command=submit_service_check
submit_service_check

Code: Select all

#!/bin/bash
#Script submit_service_check
PRINTF="/usr/bin/printf"
CMD="/usr/local/bin/send_nsca"
CFG="/etc/nagios/send_nsca.cfg"
HOST=$1
SRV=$2
RESULT=$3
OUTPUT=$4

$PRINTF "%b" "$HOST;$SRV;$RESULT;$OUTPUT\n" | $CMD -H myCentralNagios.myDomain -c $CFG -d ";"

As a test i have executed

Code: Select all

/usr/local/nagios/libexec/eventhandlers/submit_service_check  "hellotest" "test" 1 "TESTING MITCHELL"
manually and this sends a check result to my central host.

Any assistance would be greatly appreciated in resolving this matter.

Thanks,

Mitchell

Re: NSCA ocsp command not executing

Posted: Fri Apr 20, 2012 1:39 pm
by scottwilkerson
mitchsmith wrote:nagios.cfg
obsess_over_services is set to 0 as i do not want to submit check results for all just a subset. Is this correct?

Code: Select all

    obsess_over_services=0
    ocsp_timeout=60
    ocsp_command=submit_service_check
obsess_over_services needs to be 1 in the nagios.cfg otherwise it is off globally.

Re: NSCA ocsp command not executing

Posted: Fri Apr 20, 2012 2:41 pm
by mitchsmith
thanks for your reply.

I have set obsess_over_services=1

But this has not resolved the issue, the command is still not executed.

Re: NSCA ocsp command not executing

Posted: Fri Apr 20, 2012 2:52 pm
by scottwilkerson
If you go to your service in the CCM in the Check Settings tab is Obsess over service "on"?

Re: NSCA ocsp command not executing

Posted: Fri Apr 20, 2012 2:56 pm
by mitchsmith
hi,

yes obsess_over_service is on

Re: NSCA ocsp command not executing

Posted: Fri Apr 20, 2012 3:04 pm
by scottwilkerson
Just to verify, you did restart nagios correct?

Also, looking at your submit_service_check command, it doesn't seem correct, there is an odd number of quotes and ]

Code: Select all

$USER1$/eventhandlers/submit_service_check "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$ | $SERVICEPERFDATA$ [$SERVICECHECKCOMMAND$]]
Can you run it from the commandline passing arbitrary data?

Code: Select all

/usr/local/nagios/libexec/eventhandlers/submit_service_check "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$ | $SERVICEPERFDATA$ [$SERVICECHECKCOMMAND$]]

Re: NSCA ocsp command not executing

Posted: Fri Apr 20, 2012 3:12 pm
by mitchsmith
Hi,

If i execute from the command line the submit script executes:

Code: Select all

[nagios@nagiosrem oc102]$  /usr/local/nagios/libexec/eventhandlers/submit_service_check  "hellotest" "test" 1 "TESTING MITCHELL"
1 data packet(s) sent to host successfully.
[nagios@nagiosrem oc102]$

I have also tried editing the command to use the exact path to the script opposed to the $USER1$ reference

I have reloaded the configuration (Apply Configuration). Do I need to restart the nagios fully?

Re: NSCA ocsp command not executing

Posted: Fri Apr 20, 2012 3:27 pm
by scottwilkerson
Your submit_service_check command you showed above is different.

Try

Code: Select all

$USER1$/eventhandlers/submit_service_check "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$ | $SERVICEPERFDATA$"
Then restart nagios

I'm not sure but we may need to escape the |, if so it would be

Code: Select all

$USER1$/eventhandlers/submit_service_check "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$ \| $SERVICEPERFDATA$"

Re: NSCA ocsp command not executing

Posted: Fri Apr 20, 2012 3:52 pm
by mitchsmith
I tried editing the submit_service_check command to in nagios to use test data opposed to values:

Code: Select all

$USER1$/eventhandlers/submit_service_check "HOST1" "FAKESERVICE" 1 "Some Output Description"
I also added a logger line to the submit_service_check to write to a file when the script executes.

It appears that the command is not executed

Re: NSCA ocsp command not executing

Posted: Mon Apr 23, 2012 9:08 am
by scottwilkerson
What are the permissions on submit_service_check

Code: Select all

ls -l /usr/local/nagios/libexec/eventhandlers/submit_service_check
we need to make sure the nagios user can execute this...