Hi all,

Libmetrics interests me a lot. There are many projects out there (e.g., cfengine, munin) that do some level of cross-platform metric collection, and others that would do so if it were easier (e.g., nagios). All projects that use metrics seem to do their own collection right now, which is a huge waste.

However, in looking at the current interface to libmetrics, it requires that anyone using it know every available metric, and even requires that they know which metrics are available on any given platform.

So, I am wondering: Would you guys accept a patch providing a fix to some of this? I'm not such a great C developer, but this is what I would do:

1) Create a typedef struct Metric, with the metric name, a pointer to the metric function, and a pointer to the next struct (so that this could be a linked list):

typedef struct metric {
    g_val_t *function;
    char[50] name;
    Metric *next;
} Metric;

2) Create a function for searching that list for a named metric:

Metric findmetric(char *name);

which you'd use thusly:

Metric metric;
g_val_t value;
metric = findmetric("cpu_num");
value = metric.function();

This wouldn't affect how ganglia uses libmetric at first, but it would seem to make sense to convert gmond over to using this interface, for which I would also plan on submitting a patch, although maybe not in the first version.

2.5) Probably at least a 'first_metric' function, and, if I can think of any, maybe some to simplify getting a list of metrics or walking the list. I expect I won't be able to come up with a better idea than just handing the full struct to the caller, even though that wouldn't be desired in OO.

3) I'd also like to see libmetrics.{a,so} installed, either as a result of a separate flag to 'configure' or by default with gmond. I don't have a clear idea of how to do this, but I expect I can figure it out if no one else wants to do it.

Would these patches be accepted? Do people agree that they're a decent idea?

I'm not at all wedded to the specific struct or function I mentioned, they're just what I know how to do. I just want to find a way to make it so that using libmetrics doesn't require knowing exactly which metrics are available, and I especially want to avoid having to have #ifdefs for every platform in every program that uses libmetrics.

Feedback is appreciated. In the meantime, I'll begin performing this work.

--
I love deadlines. I like the whooshing sound they make as they fly by.
    --Douglas Adams
---------------------------------------------------------------------
Luke Kanies | http://abstractive.org | http://www.bladelogic.com


Reply via email to