[Nagiosplug-devel] Nagios::Plugin with scientific notation
nathan.vonnahme at bannerhealth.com
Thu Mar 20 18:29:06 CET 2008
> On 13 Mar 2008, at 17:19, Vonnahme, Nathan wrote:
> > Larry Wall said in one of his State of the Onion speeches that it's
> > better for programs (and also community members) to be "generous in
> > what
> > you accept for input and strict in what you produce as output".
> That's a good principle. I guess that means anything parsing the perf
> data should cater for scientific notation, but the plugins should only
> return a certain format.
That sounds like too much work for a small set of cases. I think it
would suffice for parsers to produce a polite error message when they
detect scientific notation (or anything else they can't handle).
> In which case, what is the precision? Can we say at the time of
> printing the value, it is something like:
> $value_as_text = sprintf("%.5f", $value);
> $value_as_text =~ s/0+$/; # Remove trailing zeros
> $value_as_text =~ s/\.$/; # Remove trailing separator
> Hmmm, different languages have different separators, so do we state
> that the value will come from the POSIX locale? (decimal point is a
> dot, no 'thousands' grouping).
> I'm thinking that the performance data doesn't need to be much more
> precise than this - Nagios plugin performance data is guidance, not
That should be plenty of precision, but I'd suggest deferring
localization to somewhere closer to the user interface layer (in this
case, the web CGIs and the notification scripts).
I doubt if any of the existing plugins produce localized output, and in
a way, producing differently punctuated output in different environments
is the opposite of being "strict".
More information about the Devel