Page 1 of 1

Inheritance and check_commands in service templates

Posted: Thu Jul 03, 2014 9:33 am
by cylindric
Is it possible to have a service inherit a service template, and have some parameters set on the service and some on the template?

I'm using CCM for configuration at the moment, and it seems to not store any parameters entered unless there is a check command, and therefore all parameters must be specified on every service, and not on a template.

Re: Inheritance and check_commands in service templates

Posted: Thu Jul 03, 2014 9:37 am
by tmcdonald
If something is set on a template and on the service that uses it, the setting in the service will override what is configured in the template. If a required config setting is not specified in either of them, you will not be able to apply the service.

Re: Inheritance and check_commands in service templates

Posted: Thu Jul 03, 2014 9:52 am
by cylindric
That doesn't really answer my question though - in CCM I have a service template with the check_command defined, and would like to specify values for $ARG1$ on the 'actual' service.

Looking at the way the arguments are defined, I guess this isn't possible, as they are not separate parameters on the service, but just a part of the check_command.

I might be able to work around this using variable definitions or something like that.

Re: Inheritance and check_commands in service templates

Posted: Thu Jul 03, 2014 10:06 am
by eloyd
You can override the check_command in the service definition and use a different command that allows you to pass the args.

Of course, you have to make a new command definition as well, but if you're mucking about in CCM, copying a command to a new one that allows args isn't too bad.

Re: Inheritance and check_commands in service templates

Posted: Fri Jul 04, 2014 12:59 am
by Box293
It sounds like you want a simple configuration pushed out to multiple hosts but each host to provide a specific value.

One way of doing this is:
  • Each host object has a custom object variable created (we'll call it _MYSETTING)
    Create a host group called MYSETTING_HOSTGROUP
    Create a service that uses MYSETTING_HOSTGROUP
    The service has the command selected
    The service needs $ARG1$ to specify the _MYSETTING value, so $ARG1$ is set to $_HOSTMYSETTING$
Here you have one service applied to many hosts with custom settings.

Some reading on custom object variables:
http://nagios.sourceforge.net/docs/3_0/ ... tvars.html

I hope this helps without causing too much confusion.

Re: Inheritance and check_commands in service templates

Posted: Fri Jul 04, 2014 4:32 pm
by eloyd
I'm not trying to "compete" with Troy, but I want to point out that my suggestion (use a different check_command that allows for ARG passing) and his suggestion (using custom host/service/contact macros) will solve slightly different problems.

So maybe it would help if you provided an example of what you're trying to accomplish? Or are you all set at this point?

Re: Inheritance and check_commands in service templates

Posted: Wed Jul 09, 2014 5:04 am
by cylindric
Yeah, thanks. The $ARGx$ pretty much solves it.

Re: Inheritance and check_commands in service templates

Posted: Wed Jul 09, 2014 8:57 am
by tmcdonald
Closing this thread now, but feel free to open another if you need anything in the future.