summaryrefslogtreecommitdiffstats
path: root/collectors
diff options
context:
space:
mode:
Diffstat (limited to 'collectors')
-rw-r--r--collectors/cgroups.plugin/sys_fs_cgroup.c4
-rw-r--r--collectors/proc.plugin/proc_diskstats.c8
-rw-r--r--collectors/proc.plugin/sys_class_infiniband.c14
3 files changed, 14 insertions, 12 deletions
diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.c b/collectors/cgroups.plugin/sys_fs_cgroup.c
index 007d4245b..d9049b2fa 100644
--- a/collectors/cgroups.plugin/sys_fs_cgroup.c
+++ b/collectors/cgroups.plugin/sys_fs_cgroup.c
@@ -1952,7 +1952,7 @@ static void is_cgroup_procs_exist(netdata_ebpf_cgroup_shm_body_t *out, char *id)
}
static inline void convert_cgroup_to_systemd_service(struct cgroup *cg) {
- char buffer[CGROUP_CHARTID_LINE_MAX];
+ char buffer[CGROUP_CHARTID_LINE_MAX + 1];
cg->options |= CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE;
strncpyz(buffer, cg->id, CGROUP_CHARTID_LINE_MAX);
char *s = buffer;
@@ -2607,7 +2607,7 @@ static inline void discovery_process_first_time_seen_cgroup(struct cgroup *cg) {
}
cg->first_time_seen = 0;
- char comm[TASK_COMM_LEN];
+ char comm[TASK_COMM_LEN + 1];
if (cg->container_orchestrator == CGROUPS_ORCHESTRATOR_UNSET) {
if (strstr(cg->id, "kubepods")) {
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");
}