]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
processes: increase reading buffer for /proc/stat 3479/head
authorMichal Humpula <michal.humpula@heureka.cz>
Thu, 11 Jun 2020 14:37:09 +0000 (16:37 +0200)
committerMichal Humpula <michal.humpula@heureka.cz>
Fri, 19 Jun 2020 13:01:14 +0000 (15:01 +0200)
If machine has high number of CPUs or interrupts or both, the /proc/stat
can easily grow over current buffer size 4kB. On my current machine (64
cores, ~300 interrupts) the /proc/stat has 12kB of data. And since the
`procs_running` line is after the interrupts it is never read.

Increasing the size to 64KB so it will accommodate even heavier machines.

src/processes.c

index 46422f295b1cb02e4c40da2a383071c9c5814c1c..ac439ddbff53313cd85586469bc3afc380cbbd5e 100644 (file)
@@ -757,7 +757,7 @@ static int ps_init(void) {
     pset_list_len = 0;
     return -1;
   }
-    /* #endif HAVE_THREAD_INFO */
+  /* #endif HAVE_THREAD_INFO */
 
 #elif KERNEL_LINUX
   pagesize_g = sysconf(_SC_PAGESIZE);
@@ -771,7 +771,7 @@ static int ps_init(void) {
     }
   }
 #endif
-    /* #endif KERNEL_LINUX */
+  /* #endif KERNEL_LINUX */
 
 #elif HAVE_LIBKVM_GETPROCS &&                                                  \
     (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
@@ -1429,7 +1429,7 @@ static int ps_read_process(long pid, process_entry_t *ps, char *state) {
 } /* int ps_read_process (...) */
 
 static int procs_running(void) {
-  char buffer[4096] = {};
+  char buffer[65536] = {};
   char id[] = "procs_running "; /* white space terminated */
   char *running;
   char *endptr = NULL;