Re: [Nagios-devel] Empty hostgroup check in the configuration

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

Re: [Nagios-devel] Empty hostgroup check in the configuration

Post by Guest »

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 [email protected]
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231





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