[collectd] Making monitoring of heterogeneous environments easier with percentage based metrics

Florian Forster octo at collectd.org
Mon Jan 13 10:50:06 CET 2014


Hi Jeremy,

On Tue, Jan 07, 2014 at 07:47:25PM -0500, Jeremy Katz wrote:
> In larger environments which have heterogeneous resources it's frequently
> useful to look at utilization of various resources as percentages.
> […]
> But all of these end up having a ton of repetition.

I agree that the amount of repetition is bad and some infrastructure to
simplify these calculations would be nice. I would, however, prefer not
to make this a truly global option.

What do you think about an interface like this:

  /* Takes a list of type instances and values and dispatches that in a
   * batch, making sure that all values have the same time stamp. If
   * "percentage" is set to true, "type" is set to "percent" and a
   * percentage is calculated and dispatched, rather than the absolute
   * values. Values that are NaN are dispatched as NaN and will not
   * influence the total. Returns the number of values it failed to
   * dispatch.
   */
  int plugin_dispatch_set (value_list_t const *vl,
      size_t          argc,
      char const    **type_instances,
      gauge_t const  *values,
      _Bool           percentage);

It would then still be up to the plugin to use this new interface, but
the changes required to each plugin would be much simpler, for example:

  char const *names[] = { "free", "cached", "buffered", "used" };
  gauge_t values[] = { NAN, NAN, NAN, NAN };
  value_list_t vl = VALUE_LIST_INIT;
  /* Init "values" and "vl". */
  plugin_dispatch_set (vl, STATIC_ARRAY_SIZE (names), names, values, 1);

Alternatively, I could picture a function with variable arguments,
that's used like this:

  __attribute__((sentinel))
  int plugin_dispatch_list (value_list_t const *vl,
      _Bool percentage, ...);
  plugin_dispatch_list (vl, 1, "free", 100.0, "cached", 200.0,
      "buffered", 300.0, "used", 1000.0, NULL);

This might be a bit easier to write, but makes it a bit error prone,
e.g. when someone forgets to add the NULL pointer (the "sentinel"
attribute should catch this on GCC). An alternative would be to pass in
the number of values, but that can't be checked during compile time
either.

Best regards,
—octo
-- 
collectd – The system statistics collection daemon
Website: http://collectd.org
Google+: http://collectd.org/+
GitHub:  https://github.com/collectd
Twitter: http://twitter.com/collectd
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mailman.verplant.org/pipermail/collectd/attachments/20140113/45591317/attachment.pgp>


More information about the collectd mailing list