[Nagios-devel] Empty hostgroup check in the configuration arbitrary

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
Guest

[Nagios-devel] Empty hostgroup check in the configuration arbitrary

Post by Guest »

------=_Part_195342_14588903.1227537554234
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello all,


Sorry if you already received this email, but I sent it one week ago
and, I don't see it in gmane archiving (and I didn't get any answer)
so I'm wondering if it reached the list.


> No, but the patch does more than you intended, since it also makes
> Nagios fail to produce warnings (or errors) in case the user has
> given a typo so that the hostgroup simply doesn't exist at all.

The checks are still done because I don't remove the execution of
xodtemplate_expand_hostgroups_and_hosts (which expands hostgroups and
hosts, look for their definition and return something like "Error:
Could not find any hostgroup matching...." if the hostgroups are not
found, same for hosts).

In a default Nagios installation, if you specify a bad name for a
hostgroup, you get two errors after a verification of the conf :
- Could not find any hostgroup matching blabla....
- Could not expand hostgroups and/or hosts specified in service blabla...

The first one is returned by xodtemplate_expand_hostgroups (same
thing for expand_hosts), and the second one by
xodtemplate_duplicate_services (the code I removed).

This second error makes the verification fail ("One or more problems
was encountered while processing the config files....etc") whereas the
first one doesn't (alone).

In a Nagios installation with my patch, the "Could not find any
hostgroup matching" errors are shown at the beginning of the
verification of the conf (nagios -v /etc/nagios/nagios.cfg) and the
verification itself ends with "Things look okay - blabla" because the
"Could not find any hostgroup matching..." error doesn't make the
verification fail.

So my second patch (see attachments) makes my modification, makes the
error propagate to the xodtemplate_duplicate_services function, and
thus makes the verification fail if the host_name/hostgroup_name is
bad (and I only get one error, the good one).

I think Nagios verification should fail when encountering the first
error, but maybe it's a development choice not to do it. I'm not
familiar with error propagations in Nagios code (and maybe in C
generally)... so your comments are welcome :-)

Thanks !
--
L.B.

------=_Part_195342_14588903.1227537554234
Content-Type: text/x-patch; name=hostgroup_empty2.patch
Content-Transfer-Encoding: base64
X-Attachment-Id: f_fnpv2tzd0
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ciBldmVyeSBob3N0IGluIHRoZSBob3N0Z3JvdXAvaG9zdCBu
YW1lIGxpc3QgKi8KIAkJZmlyc3RfaXRlbT1UUlVFOwpAQCAtMTM2MjIsNiArMTM2MTgsOCBAQAog
CiAJCS8qIGV4cGFuZCBob3N0ICovCiAJCXJlc3VsdD14b2R0ZW1wbGF0ZV9leHBhbmRfaG9zdGdy
b3VwcygmdGVtcF9saXN0LCZyZWplY3RfbGlzdCxob3N0Z3JvdXBzLF9jb25maWdfZmlsZSxfc3Rh
cnRfbGluZSk7CisJCWlmKHJlc3VsdD09RVJST1IpCisJCQlyZXR1cm4gRVJST1I7CiAJCWlmKHJl
c3VsdCE9T0spewogCQkJeG9kdGVtcGxhdGVfZnJlZV9tZW1iZXJsaXN0KCZ0ZW1wX2xpc3QpOwog
CQkJeG9kdGVtcGxhdGVfZnJlZV9tZW1iZXJsaXN0KCZyZWplY3RfbGlzdCk7CkBAIC0xMzYzNCw2
ICsxMzYzMiw4IEBACiAKIAkJLyogZ

...[email truncated]...


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