Page 1 of 1

Re: [Nagios-devel] Nagios implied and additive inheritance;

Posted: Thu Mar 29, 2012 4:49 am
by Guest
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

On 12-03-28 01:46 PM, Jochen Bern wrote:
>
> I tried that myself a while back, and dug into the (3.2.x) code when it
> didn't work for me, either. (I'll assume that the relevant code is still
> the same in 3.3.1.) The fact of the matter is that in
> xdata/xodtemplate.c:xodtemplate_read_config_data(), you have calls - in
> this order - to
>
> 1. xodtemplate_resolve_objects(), which calls
> xodtemplate_resolve_service() on all service objects, which applies
> all templates, using xodtemplate_get_inherited_string() *IFF* both
> service and template have the corresponding config setting, which
> does the additive inheritance,
>
> 2. xodtemplate_clean_additive_strings(), which silently removes any
> surviving "+" from contacts and contact groups settings of all
> objects except host and service escalations, and
>
> 3. xodtemplate_inherit_object_properties(), which does the host-to-
> service inheritance.
>
> They're not sitting *next* to each other, though - in particular, most
> of the "recombombulation" stuff intervenes between 2. and 3. - and
> turning things around would introduce a behavioral change for identical
> configs (= bad), anyway, so I never even tried to write a patch.

I've noticed this annoying issue a while back, but I didn't look much
into the logic there - that's a very nice overview of the issue.

So indeed changing things around isn't going to work, however there
might be another way to fix it. In #1,
xodtemplate_get_inherited_string() basically concatenate strings
together starting from the template. This meand that the order is
preserved, and if I get this right, in the end the + sign at the
beginning of the string is meaningful.

In #2, remove the +'es *except the first one* for anything that will be
processed by xodtemplate_inherit_object_properties()

#3a. contact* still have the + around, so inherit if NULL or [0] == '+',
so we inherit. User Happy!

#3b. process the inherited strings again with
xodtemplate_clean_additive_strings()


It will obviously change the behavior - anyone that end up with a + in
the begining of the strings will inherit - however I think it's limited
and can be fixed by first inheriting an empty contact group. It might be
possible to also add a switch to detect such errors when upgrading so
people using inheritance could see warnings in the verification pass.

What do you think?

- --
Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9z98AACgkQ6dZ+Kt5Bchb/qQCgsCz6kvRCpNOX5L/ZutDdwzFO
96UAoM/SF85/nWMRKtfWqy3MHKYzrjAV
=R78b
-----END PGP SIGNATURE-----





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