From: tiozhang Date: Fri, 5 May 2023 03:36:33 +0000 (+0800) Subject: processes: determine if ctxt is enabled before read_sys_ctxt_switch X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2626382c6f0c506993ec13c4c2bcd69bad19371;p=thirdparty%2Fcollectd.git processes: determine if ctxt is enabled before read_sys_ctxt_switch Signed-off-by: tiozhang Signed-off-by: luffysong --- diff --git a/src/processes.c b/src/processes.c index 8fe880f43..dd03bab29 100644 --- a/src/processes.c +++ b/src/processes.c @@ -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;