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

Andreas Ericsson ae at op5.se
Tue Nov 25 08:27:48 CET 2008


L B wrote:
> 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....

This is the typo-catching check, so we'll focus on that.

>  - 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.
> 

But it did before, didn't it?

> 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 :-)
> 

Right. I'll give it a whirl later today. Thanks for the resend.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

-------------------------------------------------------------------------
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=/




More information about the Developers mailing list