fix infiniband bytes counters multiplier and divisor (#14748)
Ilya Mashchenko committed
May 16, 2023 at 18:25 UTC
3b3c917cafccba5e6e5f4afc03b8d51f91ff4e88
1 file changed
+8
-6
collectors/proc.plugin/sys_class_infiniband.c
+8
-6
@@ -469,15 +469,17 @@ int do_sys_class_infiniband(int update_every, usec_t dt)
469
// Sample output: "100 Gb/sec (4X EDR)"
470
snprintfz(buffer, FILENAME_MAX, "%s/%s/%s", ports_dirname, port_dent->d_name, "rate");
471
char buffer_rate[65];
472
+ p->width = 4;
473
if (read_file(buffer, buffer_rate, 64)) {
474
collector_error("Unable to read '%s'", buffer);
474
- p->width = 1;
475
} else {
476
char *buffer_width = strstr(buffer_rate, "(");
477
- buffer_width++;
478
- // str2ull will stop on first non-decimal value
479
- p->speed = str2ull(buffer_rate, NULL);
480
- p->width = str2ull(buffer_width, NULL);
477
+ if (buffer_width) {
478
+ buffer_width++;
479
+ // str2ull will stop on first non-decimal value
480
+ p->speed = str2ull(buffer_rate, NULL);
481
+ p->width = str2ull(buffer_width, NULL);
482
+ }
483
}
484
485
if (!p->discovered)
@@ -541,7 +543,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt)
543
// On this chart, we want to have a KB/s so the dashboard will autoscale it
544
// The reported values are also per-lane, so we must multiply it by the width
545
// x4 lanes multiplier as per Documentation/ABI/stable/sysfs-class-infiniband
544
- FOREACH_COUNTER_BYTES(GEN_RRD_DIM_ADD_CUSTOM, port, 4 * 8 * port->width, 1024, RRD_ALGORITHM_INCREMENTAL)
546
+ FOREACH_COUNTER_BYTES(GEN_RRD_DIM_ADD_CUSTOM, port, port->width * 8, 1000, RRD_ALGORITHM_INCREMENTAL)
547
548
port->stv_speed = rrdsetvar_custom_chart_variable_add_and_acquire(port->st_bytes, "link_speed");
549
}