]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
processes: determine if ctxt is enabled before read_sys_ctxt_switch
authortiozhang <zyhtheonly@yeah.net>
Fri, 5 May 2023 03:36:33 +0000 (11:36 +0800)
committerMatthias Runge <mrunge@matthias-runge.de>
Mon, 22 May 2023 16:49:12 +0000 (18:49 +0200)
Signed-off-by: tiozhang <zyhtheonly@yeah.net>
Signed-off-by: luffysong <zsfz_one@163.com>
src/processes.c

index 8fe880f437e8d470fa2640d49427726b645fa4bc..dd03bab29e030d391a663dccc98fb1e5cb8962ee 100644 (file)
@@ -1622,8 +1622,7 @@ static int read_sys_ctxt_switch(const char *buffer) {
   if (status != 0)
     return -1;
 
-  if (report_sys_ctxt_switch)
-    ps_submit_global_stat("contextswitch", value.derive);
+  ps_submit_global_stat("contextswitch", value.derive);
   return 0;
 }
 #endif /*KERNEL_LINUX */
@@ -2176,8 +2175,9 @@ static int ps_read(void) {
     ps_submit_proc_list(ps_ptr);
 
   read_fork_rate(buffer);
-  read_sys_ctxt_switch(buffer);
-  /* #endif KERNEL_LINUX */
+  if (report_sys_ctxt_switch)
+    read_sys_ctxt_switch(buffer);
+    /* #endif KERNEL_LINUX */
 
 #elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD
   int running = 0;