check_command generated using 'check command_name' field?

Support requests, bug reports, questions etc.
Locked
cpdiety
check_command generated using 'check command_name' field?

Post by cpdiety » Sat Mar 28, 2009 02:07

It appears as though the check_command field in service definitions is generated using the 'check command name' field. I would expect this to be generated from 'check command line' instead. The specific use case is as follows:

I'm using nrpe to monitor (amongst other things) the load on my servers. With nrpe you call check_nrpe with the specific command as a parameter (e.g. check_nrpe!check_load). As a result of this, I would like to create multiple service definitions, one per command to be executed using nrpe.

I started by defining the check_load service as follows:
'check command name' => 'nrpe: check_load'
'check command line' => 'check_nrpe'
'default command params' => '!check_load'

I would have expected this to generate:

Code: Select all

                service_description                   nrpe: check_load
                check_command                         check_nrpe!check_load
The actual output was as follows:

Code: Select all

                service_description                   nrpe: check_load
                check_command                         nrpe: check_load!check_load
It is entirely possible that I simply don't understand the intended method for configuring such a service. Any help would be greatly appreciated.

User avatar
agargiulo
NConf developer
NConf developer
Posts:725
Joined:Fri Mar 06, 2009 17:50
Location:Zurich, Switzerland
Contact:

Re: check_command generated using 'check command_name' field?

Post by agargiulo » Mon Mar 30, 2009 10:59

Hi. The files we generate have the following structure:

filename: services.cfg

Code: Select all

define service {
                service_description                   service name
                check_command                         check command name !user-arg1, ...
                host_name                             ....
                ...   
}
filename: checkcommands.cfg

Code: Select all

define command {
                command_name                          check command name
                command_line                          $USER1$/checkcommand ... $ARG1$
}
The 'check command name' in services.cfg file references the one in checkcommands.cfg. This way a command + its static parameters only needs to be specified once, but the user can still configure his own command arguments.

cpdiety

Re: check_command generated using 'check command_name' field?

Post by cpdiety » Mon Mar 30, 2009 19:40

Thank you for replying. I thought I had looked for that, but I guess I missed it.

rapatel

Re: check_command generated using 'check command_name' field?

Post by rapatel » Thu Apr 23, 2009 14:32

I had a question in this area - the problem is I want to define commands that use the check_nrpe command so that they can be added to Host templates. The problem is that with services tied to specific hosts, there is no way to create a generic service say "CPULoad" that calls the command check_nrpe with arg check_load and make the CPULoad service part of the host. Can a command line contain a reference to another command w/ arg? ie create a "CPULoad" command that calls the "check_nrpe" command with arg "check_load"? That would save a lot of trouble, otherwise for every host to be created, we have to manually create a service for each command being run by nrpe for that host. Way too much manual work.

Our current Nagios2 config has a service for each host that has for example:

define service{
use local-service
host_name server1
service_description Current Load
check_command check_nrpe!check_load
}

define service{
use local-service
host_name server1
service_description Current Users
check_command check_nrpe!check_users
}


How do we have host templates that can generate those services without manually creating them for each host?

Thanks!

rapatel

Re: check_command generated using 'check command_name' field?

Post by rapatel » Thu Apr 23, 2009 14:50

Never mind - I tried originally using a command CPULoad with a call to the nrpe command line with "-c check_load" for example, but in my testing had mis-typed it and got confused as to why it would not work.

Defining each command with direct call to NRPE will work since each command can be in the appropriate host templates.

User avatar
agargiulo
NConf developer
NConf developer
Posts:725
Joined:Fri Mar 06, 2009 17:50
Location:Zurich, Switzerland
Contact:

Re: check_command generated using 'check command_name' field?

Post by agargiulo » Thu Apr 23, 2009 15:59

This tread could also be related:

viewtopic.php?f=5&t=50

Locked