2.0b1 patch to make unreachables fully work, and some commentary
Andreas Ericsson
ae at op5.se
Tue Jan 4 13:08:21 CET 2005
Joe Pruett wrote:
> i just started installing a 2.0b1 installation and couldn't figure out why
> i would get unreachable email messages, but nothing would show in the web
> interface. i finally found the bug (patch below). but along the way
> while trying to figure out what was going on i got very confused by the
> different uses of state inside the code. there are #defines for HOST_UP,
> _DOWN, _UNREACHABLE, etc with values like 1, 2, 4. but the status file
> uses 0, 1, 2. similar issues seem to apply to services. and nowhere was
> an obvious conversion between the two. is this some historical artifact?
>
I believe they were once intended to be used as flags, although that's
very much deprecated now that the status codes are of mutex types.
> anyway, after poking around i finally found that the problem was in the
> xsddefault.c file that was converting the current_state into a boolean,
> rather than just leaving it as is. my fix seems to have the correct
> functionality.
>
That can't possibly be the case.
With the fix applied, temp_hoststatus->status can still only be 1 or 0
(the result of the boolean operation atoi(val) > 0). Ethan's way of
writing it was just a bit more cumbersome (and a bit clearer).
> --- xdata/xsddefault.c.orig 2005-01-03 20:14:18.000000000 -0800
> +++ xdata/xsddefault.c 2005-01-03 20:15:12.000000000 -0800
> @@ -638,7 +638,7 @@
> else if(!strcmp(var,"check_latency"))
> temp_hoststatus->latency=strtod(val,NULL);
> else if(!strcmp(var,"current_state"))
> - temp_hoststatus->status=(atoi(val)>0)?TRUE:FALSE;
> + temp_hoststatus->status=atoi(val)>0;
> else if(!strcmp(var,"last_hard_state"))
> temp_hoststatus->last_hard_state=atoi(val);
> else if(!strcmp(var,"plugin_output"))
>
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by: Beat the post-holiday blues
> Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> _______________________________________________
> Nagios-devel mailing list
> Nagios-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-devel
>
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Lead Developer
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
More information about the Developers
mailing list