NSCA ocsp command not executing

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
mitchsmith
Posts: 33
Joined: Mon Apr 04, 2011 7:26 am

NSCA ocsp command not executing

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NSCA ocsp command not executing

Post 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.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
mitchsmith
Posts: 33
Joined: Mon Apr 04, 2011 7:26 am

Re: NSCA ocsp command not executing

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NSCA ocsp command not executing

Post by scottwilkerson »

If you go to your service in the CCM in the Check Settings tab is Obsess over service "on"?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
mitchsmith
Posts: 33
Joined: Mon Apr 04, 2011 7:26 am

Re: NSCA ocsp command not executing

Post by mitchsmith »

hi,

yes obsess_over_service is on
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NSCA ocsp command not executing

Post 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$]]
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
mitchsmith
Posts: 33
Joined: Mon Apr 04, 2011 7:26 am

Re: NSCA ocsp command not executing

Post 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?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NSCA ocsp command not executing

Post 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$"
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
mitchsmith
Posts: 33
Joined: Mon Apr 04, 2011 7:26 am

Re: NSCA ocsp command not executing

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NSCA ocsp command not executing

Post 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...
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked