<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 13, 2014 at 4:50 AM, Florian Forster <span dir="ltr"><<a href="mailto:octo@collectd.org" target="_blank">octo@collectd.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, Jan 07, 2014 at 07:47:25PM -0500, Jeremy Katz wrote:<br>
> In larger environments which have heterogeneous resources it's frequently<br>
> useful to look at utilization of various resources as percentages.<br>
</div>> […]<br>
<div class="im">> But all of these end up having a ton of repetition.<br>
<br>
</div>I agree that the amount of repetition is bad and some infrastructure to<br>
simplify these calculations would be nice. I would, however, prefer not<br>
to make this a truly global option.<br></blockquote><div><br></div><div>I can definitely go either way.  I just think that the number of places it will apply is going to actually be pretty high.  Going through and adding ReportAbsolute and ReportPercentage to relevant plugins isn't hard either, though with either of the options below.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What do you think about an interface like this:<br></blockquote><div>[snip] </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  int plugin_dispatch_set (value_list_t const *vl,<br>
      size_t          argc,<br>
      char const    **type_instances,<br>
      gauge_t const  *values,<br>
      _Bool           percentage);<br></blockquote><div>[snip] </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  __attribute__((sentinel))<br>
  int plugin_dispatch_list (value_list_t const *vl,<br>
      _Bool percentage, ...);<br>
  plugin_dispatch_list (vl, 1, "free", 100.0, "cached", 200.0,<br>
      "buffered", 300.0, "used", 1000.0, NULL);<br></blockquote><div> </div><div>The varargs version feels a little cleaner and easier to use in plugins where there are lots of possibilities for different sets of values as many of these will be.  That said, both would work so I don't know that I'd feel that strongly.  As Yves says, you can screw either up really :)</div>
<div><br></div><div>- Jeremy</div></div></div></div>