[Nagiosplug-devel] printf calls in library functions
Ton Voon
ton.voon at altinity.com
Mon Jul 23 12:20:24 CEST 2007
Hi,
On 22 Jul 2007, at 18:08, Matthias Eble wrote:
> we have an item in the Bugtracker (#1681516) that claims, that the
> output for various checks is too verbose due to printf statements in
> some library functions (for example netutils and sslutils).
>
> Example:
>> ./check_http -H foo -S
>> Name or service not known
>> HTTP CRITICAL - Unable to open TCP socket
>
>
> I'd like to know what you think about printing to stdout/stderr in a
> library. I see two possibilities to solve the issue:
>
> 1st: Always die on an error in a library (accepting the lack of the
> plugin name string in the output.
> 2nd: Add a verbosity argument to the library functions
My initial feeling is to not use stderr at all and all errors go to
stdout.
Usually when you have errors in the library, it is left to the
calling program can decide what to do with the error. But in our
case, I think we could always exit with UNKNOWN and the error
message. This would also have the advantage of having a consistent
error message and simpler programming at the plugin level.
For warnings type messages, it would make sense to use the verbosity
flag (though I'm not sure of any examples right now).
Comments?
> Btw: Why are the sslutils, etc located in the plugin directory?
Historical. We had issues compiling from an external directory
before. I'm happy to have them moved to lib/ now that the
infrastructure is in place to allow this easily.
Ton
http://www.altinity.com
T: +44 (0)870 787 9243
F: +44 (0)845 280 1725
Skype: tonvoon
More information about the Devel
mailing list