diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-18 14:38:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-18 14:38:05 +0000 |
commit | ab2714ee67d23dc115edfc0e2bb82ab88cc17b57 (patch) | |
tree | bb9dd1e8750fea4bea85e590e36ca636f9128ad2 /collectors/proc.plugin | |
parent | Adding upstream version 1.39.0. (diff) | |
download | netdata-upstream/1.39.1.tar.xz netdata-upstream/1.39.1.zip |
Adding upstream version 1.39.1.upstream/1.39.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/proc.plugin')
-rw-r--r-- | collectors/proc.plugin/proc_diskstats.c | 8 | ||||
-rw-r--r-- | collectors/proc.plugin/sys_class_infiniband.c | 14 |
2 files changed, 12 insertions, 10 deletions
diff --git a/collectors/proc.plugin/proc_diskstats.c b/collectors/proc.plugin/proc_diskstats.c index 2a4fe4f8c..09c6498e3 100644 --- a/collectors/proc.plugin/proc_diskstats.c +++ b/collectors/proc.plugin/proc_diskstats.c @@ -348,7 +348,7 @@ static inline int get_disk_name_from_path(const char *path, char *result, size_t int found = 0, preferred = 0; - char *first_result = mallocz(result_size); + char *first_result = mallocz(result_size + 1); DIR *dir = opendir(path); if (!dir) { @@ -454,7 +454,7 @@ failed: } static inline char *get_disk_name(unsigned long major, unsigned long minor, char *disk) { - char result[FILENAME_MAX + 1] = ""; + char result[FILENAME_MAX + 2] = ""; if(!path_to_device_mapper || !*path_to_device_mapper || !get_disk_name_from_path(path_to_device_mapper, result, FILENAME_MAX + 1, major, minor, disk, NULL, 0)) if(!path_to_device_label || !*path_to_device_label || !get_disk_name_from_path(path_to_device_label, result, FILENAME_MAX + 1, major, minor, disk, NULL, 0)) @@ -615,8 +615,8 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis // read device uuid if it is an LVM volume if (!strncmp(d->device, "dm-", 3)) { char uuid_filename[FILENAME_MAX + 1]; - snprintfz(uuid_filename, FILENAME_MAX, path_to_sys_devices_virtual_block_device, disk); - strncat(uuid_filename, "/dm/uuid", FILENAME_MAX); + int size = snprintfz(uuid_filename, FILENAME_MAX, path_to_sys_devices_virtual_block_device, disk); + strncat(uuid_filename, "/dm/uuid", FILENAME_MAX - size); char device_uuid[RRD_ID_LENGTH_MAX + 1]; if (!read_file(uuid_filename, device_uuid, RRD_ID_LENGTH_MAX) && !strncmp(device_uuid, "LVM-", 4)) { diff --git a/collectors/proc.plugin/sys_class_infiniband.c b/collectors/proc.plugin/sys_class_infiniband.c index f0b7f9a52..d12a34513 100644 --- a/collectors/proc.plugin/sys_class_infiniband.c +++ b/collectors/proc.plugin/sys_class_infiniband.c @@ -469,15 +469,17 @@ int do_sys_class_infiniband(int update_every, usec_t dt) // Sample output: "100 Gb/sec (4X EDR)" snprintfz(buffer, FILENAME_MAX, "%s/%s/%s", ports_dirname, port_dent->d_name, "rate"); char buffer_rate[65]; + p->width = 4; if (read_file(buffer, buffer_rate, 64)) { collector_error("Unable to read '%s'", buffer); - p->width = 1; } else { char *buffer_width = strstr(buffer_rate, "("); - buffer_width++; - // str2ull will stop on first non-decimal value - p->speed = str2ull(buffer_rate, NULL); - p->width = str2ull(buffer_width, NULL); + if (buffer_width) { + buffer_width++; + // str2ull will stop on first non-decimal value + p->speed = str2ull(buffer_rate, NULL); + p->width = str2ull(buffer_width, NULL); + } } if (!p->discovered) @@ -541,7 +543,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) // On this chart, we want to have a KB/s so the dashboard will autoscale it // The reported values are also per-lane, so we must multiply it by the width // x4 lanes multiplier as per Documentation/ABI/stable/sysfs-class-infiniband - FOREACH_COUNTER_BYTES(GEN_RRD_DIM_ADD_CUSTOM, port, 4 * 8 * port->width, 1024, RRD_ALGORITHM_INCREMENTAL) + FOREACH_COUNTER_BYTES(GEN_RRD_DIM_ADD_CUSTOM, port, port->width * 8, 1000, RRD_ALGORITHM_INCREMENTAL) port->stv_speed = rrdsetvar_custom_chart_variable_add_and_acquire(port->st_bytes, "link_speed"); } |