Page 1 of 1

Re: [Nagios-devel] Multiple Inheritance Sources and

Posted: Wed Aug 22, 2007 8:55 am
by Guest
L B wrote:
> Hi all,
>
> I've read the end of this page
> https://nagios.sgs.net/nagios/docs/obje ... tance.html
> about
> multiple inheritance sources.
>
> I'm going to explain what I want with an example :
>
> I have a template for windows-servers with an hostgroups variable defined.
> I have another template for ABC-servers with also an hostgroups variable
> defined ( ABC is a project name).
>
> I want my server to belong to both.
>
> I defined a new host like this :
>
> define host {
> name windows-server
> hostgroups windows-server
> ...
> register 0
> }
> define host {
> name ABC-server
> hostgroups ABC-server
> ...
> register 0
> }
>
> define host {
> use windows-server,ABC-server
> ...
> }
>
> The problem, and according to the documentation, is that only the
> hostgroups variable of the first template is kept.
>
> Is it possible to add a concatenation feature to this inheritance, for
> example by adding a + in front of the hostgroups name ?
>
> If I define a template like this :
> define host {
> name ABC-server
> hostgroups +ABC-server
> ...
> register 0
> }
>
> I would like the hostgroups variable to be concatenated to the previous
> ones inherited from other templates.
>
> I thought it was the expected behavior but it doesn't work.
>
> Thanks,
> --
> L.B.

The "+" concatentation trick works with only one level of recursion and
not with multiple inheritance sources. Also, Nagios will inherit values
from the first template (as you specify) in which they are found.

Nagios sees that the windows-server template already has a hostgroups
variable defined, so it won't use the value from the ABC-server template.

So in order to accomplish what you want, you have two options.

The first option:

define host {
name windows-server
hostgroups windows-server
...
register 0
}

define host {
use windows-server
hostgroups +ABC-server
...
}

The second option:

define host{
name windows-server
hostgroups windows-server
...
register 0
}

define host {
name ABC-server
use windows-server
hostgroups +ABC-server
...
register 0
}

define host {
use ABC-server
...
}


Ethan Galstad,
Nagios Developer
---
Email: [email protected]
Website: http://www.nagios.org





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]