Inheritance and check_commands in service templates

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
cylindric
Posts: 40
Joined: Wed May 29, 2013 9:50 am

Inheritance and check_commands in service templates

Post 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.
Cyl
Nagios Core 4.3.4 on Ubuntu 16.04.3
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Inheritance and check_commands in service templates

Post 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.
Former Nagios employee
cylindric
Posts: 40
Joined: Wed May 29, 2013 9:50 am

Re: Inheritance and check_commands in service templates

Post 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.
Cyl
Nagios Core 4.3.4 on Ubuntu 16.04.3
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Inheritance and check_commands in service templates

Post 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.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Inheritance and check_commands in service templates

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Inheritance and check_commands in service templates

Post 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?
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
cylindric
Posts: 40
Joined: Wed May 29, 2013 9:50 am

Re: Inheritance and check_commands in service templates

Post by cylindric »

Yeah, thanks. The $ARGx$ pretty much solves it.
Cyl
Nagios Core 4.3.4 on Ubuntu 16.04.3
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Inheritance and check_commands in service templates

Post by tmcdonald »

Closing this thread now, but feel free to open another if you need anything in the future.
Former Nagios employee
Locked