Obsessive compulsive command is not being called


#1

Here are the only settings I think are relevant, if I’ve missed something, that may be the problem!

obsess_over_services=1
ocsp_command=submit_check_result

define command{
command_name submit_check_result
command_line /usr/local/nagios/libexec/eventhandlers/submit_check_result $HOSTNAME$ ‘$SERVICEDESC$’ $SERVICESTATE$ ‘$OUTPUT$’ | tee -a /tmp/nagios.log
}

I’ve put the tee command in to log if this command was actually being called. There is no output in this log unless I run the submit__check_result manually.

I’ve only set up the check_cron on the client, and it is being run successfully every minute… so why isn’t the submit_check_result being called?


#2

what’s the content of /usr/local/nagios/libexec/eventhandlers/submit_check_result?
How are the permisions set on that file?

Luca
Edited Tue Feb 07 2006, 09:59AM ]


#3

-rwxr-xr-x 1 nagios nagios 969 Feb 7 14:04 submit_check_result
hostname:/usr/local/nagios/libexec/eventhandlers #

It runs successfully when executed manually as the nagios user, it just doesn’t ever get called by Nagios?

Thanks Luca.


#4

did you try following the instructions in the sticky thread “how to best use NCSA”? there’s some useful info… i’m no big expert at it. :slight_smile:

Luca

PS: i just read this in your fierrst post:
"I’ve only set up the check_cron on the client, and it is being run successfully every minute… so why isn’t the submit_check_result being called?"
submit check result should not be called directly… you shoul dbe checking some value on the local machine to be sent to the central nagios server…

Edited Wed Feb 08 2006, 11:27AM ]


#5

Thanks Luca. I re-read the NSCA thread, but couldn’t find anything.

I don’t understand your PS, maybe I’m missing something… this is how I understand the process.

I’m trying to set up a distributed monitor.
distributed-host is running nagios and check client-a using nrpe, client-a returns its result and is supposed to run the submit_check_result command due to “obsess_over_services=1” and “ocsp_command=submit_check_result”. Obsess over service then uses send_nsca to pass results over to the central server.
The distributed server also has obssess_over_service=1, so it should return all results.


#6

Thanks Luca. I re-read the NSCA thread, but couldn’t find anything.

I don’t understand your PS, maybe I’m missing something… this is how I understand the process.

I’m trying to set up a distributed monitor.
distributed-host is running nagios and check client-a using nrpe, client-a returns its result and is supposed to run the submit_check_result command due to “obsess_over_services=1” and “ocsp_command=submit_check_result”. Obsess over service then uses send_nsca to pass results over to the central server.
The distributed server also has obssess_over_service=1, so it should return all results.


#7

as for my PS i re read it myself and it looks like i misunderstood you :smiley:

but what i’m not sure about what you wrote now is: The main host is checking via NRPE and the remote host uses NSCA to send the result back? that is wrong. either you use NRPE or you use NSCA… if you use NSCA the check is remotely initiated by the nagios instance which sends the result to the main server, in NRPE it’s the central server who runs the plugins remotely so there should be no need for nagios on the remote host. (this is how i understood it, no tusing NRPE i’m not really sure)

Luca


#8

[quote=“ben”]…
define command{
command_name submit_check_result
command_line /usr/local/nagios/libexec/eventhandlers/submit_check_result $HOSTNAME$ ‘$SERVICEDESC$’ $SERVICESTATE$ ‘$OUTPUT$’ | tee -a /tmp/nagios.log
}
…[/quote]

Take out that pipe and the rest and try it like that. Outputting to a log file might need to be done in the submit_check_result script anyway.

su - nagios
then run the command by hand substituting some string in place of the variables. For example $OUTPUT$ should be “test_output_string”.


#9

jakkedup

As the nagios user the submit_check_results works, with or without the tee command. I put the tee command there to prove that the submit_check_result was never being called.

luca
The distributed host checks the client using nrpe, receives the result and then should forward the result using the submit_nsca command inside the submit_check_result script, which should be called due to the obssessive compulsive command.


#10

Please show us the contents of the script and verify that it is correct syntax.
/usr/local/nagios/libexec/eventhandlers/submit_check_result


#11

Here it is, I changed my host-ip though.

#!/bin/sh

Arguments:

$1 = host_name (Short name of host that the service is

associated with)

$2 = svc_description (Description of the service)

$3 = state_string (A string representing the status of

the given service - “OK”, “WARNING”, “CRITICAL”

or “UNKNOWN”)

$4 = plugin_output (A text string that should be used

as the plugin output for the service checks)

Convert the state string to the corresponding return code

return_code=-1

case “$3” in
OK)
return_code=0
;;
WARNING)
return_code=1
;;
CRITICAL)
return_code=2
;;
UNKNOWN)
return_code=-1
;;
esac

    # pipe the service check info into the send_nsca program, which
    # in turn transmits the data to the nsca daemon on the central
    # monitoring server

/bin/echo "submit_check_result ran date" >> /tmp/nagios.log

    /bin/echo "$1   $2      $return_code    $4" | /usr/local/nagios/bin/send_nsca xxx.xxx.xxx.xxx -p 5667 -c /usr/local/nagios/etc/send_nsca.cfg

#12

From my tests, the format of your last line is missing tabs(\t).
Try these 2 command lines and see which one works. Only the last one worked for me.
YOUR FORMAT:
/bin/echo “SOMEREALHOSTNAME VALIDSERVICEDESC 1 TEST” | /usr/local/nagios/bin/send_nsca xxx.xxx.xxx.xxx -p 5667 -c /usr/local/nagios/etc/send_nsca.cfg
SUGGESTED FORMAT:
/bin/echo “SOMEREALHOSTNAME\tVALIDSERVICEDESC\t1\tTEST\n” | /usr/local/nagios/bin/send_nsca xxx.xxx.xxx.xxx -p 5667 -c /usr/local/nagios/etc/send_nsca.cfg

FYI: in order to get a backslash \ to show up in this forum, you have to type 2 of them in a row. Like this:
I type 2 backslashes \ and yet you only see one of them.

Edited Mon Feb 13 2006, 02:28PM ]


#13

I’ve got actual tabbed space in the last line by pressing control-v-tab. This script does work and updates the Nagios server when I run it. It just doesn’t ever get run by nagios.


#14

Most likely nagios doesn’t like your syntax and I’ve stated already what the syntax should look like. If you choose to change that syntax and it doesn’t work, then please stop asking for assistance, since you already know how it should work, apparently. Control-v-tab instead of \t


#15

jakked up,

Thanks for the help, but there is no need to be rude. If you look at any of my posts or the heading, the problem is that the obsessive compulsive command is not being called. Not that it doesn’t work. Nagios does like my syntax as I previously stated, when I run the script it works.


#16

Sorry 'bout being rude. I only figured it wouldn’t hurt to at least try a suggestion. I don’t have the time to try your syntax and test it, but then, I"m not the one with the problem. Good luck.


#17

I have tried it with the \t as well. Same result.
Thanks anyway.

I’m going to implement a full passive setup now, which will be better for our environment anyway.


#18

I’m not sure I understand what you have done here. You do realize that these settings/command definitions are made on the REMOTE host that will attempt to send the output of service checks to the central nagios server.