Empty hostgroup check in the configuration arbitrary or limitation in nagios core ?

L B bertignac at gmail.com
Mon Nov 24 15:39:14 CET 2008


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hostgroup_empty2.patch
Type: text/x-patch
Size: 2022 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20081124/f6203954/attachment.bin>
-------------- next part --------------
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list