return gpu_config_init(count);
}
+static double metric2double(metric_type_t type, value_t value) {
+ switch (type) {
+ case METRIC_TYPE_GAUGE:
+ return value.gauge;
+ case METRIC_TYPE_COUNTER:
+ return value.counter;
+ case METRIC_TYPE_COUNTER_FP:
+ return value.counter_fp;
+ case METRIC_TYPE_UP_DOWN:
+ return value.up_down;
+ case METRIC_TYPE_UP_DOWN_FP:
+ return value.up_down_fp;
+ case METRIC_TYPE_UNTYPED:
+ break;
+ }
+ assert(0);
+}
+
/* Add device labels to all metrics in given metric family and submit family to
* collectd, and log the metric if metric logging is enabled.
* Resets metric family after dispatch */
}
INFO("[%7ld.%03ld] %s: %s / %s [%ld]: %.3f", ts.tv_sec,
ts.tv_nsec / 1000000, pci_bdf, name, type, i,
- fam->type == METRIC_TYPE_COUNTER ? m->value.counter
- : m->value.gauge);
+ metric2double(fam->type, m->value));
}
/* add extra per-metric labels */
assert(len < bufsize);
}
-static double get_value(metric_type_t type, value_t value) {
- switch (type) {
- case METRIC_TYPE_COUNTER:
- return value.counter;
- break;
- case METRIC_TYPE_GAUGE:
- return value.gauge;
- break;
- default:
- assert(0);
- }
-}
-
/* matches constructed metric names against validation array ones and
* updates the values accordingly
*/
metric_t *metric = fam->metric.ptr;
for (size_t m = 0; m < fam->metric.num; m++) {
- double value = get_value(fam->type, metric[m].value);
+ double value = metric2double(fam->type, metric[m].value);
compose_name(name, sizeof(name), fam->name, &metric[m]);
if (globs.verbose & VERBOSE_METRICS) {
fprintf(stderr, "METRIC: %s: %g\n", name, value);