Skip to content

Commit

Permalink
fixed freebsd cpu calculation (netdata#18648)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsaou authored Sep 30, 2024
1 parent b8c8e44 commit 0689f2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/collectors/apps.plugin/apps_os_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ bool apps_os_read_pid_stat_freebsd(struct pid_stat *p, void *ptr) {
pid_incremental_rate(stat, PDF_CMINFLT, (kernel_uint_t)proc_info->ki_rusage_ch.ru_minflt);
pid_incremental_rate(stat, PDF_MAJFLT, (kernel_uint_t)proc_info->ki_rusage.ru_majflt);
pid_incremental_rate(stat, PDF_CMAJFLT, (kernel_uint_t)proc_info->ki_rusage_ch.ru_majflt);
pid_incremental_rate(stat, PDF_UTIME, (kernel_uint_t)proc_info->ki_rusage.ru_utime.tv_sec * NSEC_PER_SEC + proc_info->ki_rusage.ru_utime.tv_usec * NSEC_PER_USEC);
pid_incremental_rate(stat, PDF_STIME, (kernel_uint_t)proc_info->ki_rusage.ru_stime.tv_sec * NSEC_PER_SEC + proc_info->ki_rusage.ru_stime.tv_usec * NSEC_PER_USEC);
pid_incremental_rate(stat, PDF_CUTIME, (kernel_uint_t)proc_info->ki_rusage_ch.ru_utime.tv_sec * NSEC_PER_SEC + proc_info->ki_rusage_ch.ru_utime.tv_usec * NSEC_PER_USEC);
pid_incremental_rate(stat, PDF_CSTIME, (kernel_uint_t)proc_info->ki_rusage_ch.ru_stime.tv_sec * NSEC_PER_SEC + proc_info->ki_rusage_ch.ru_stime.tv_usec * NSEC_PER_USEC);
pid_incremental_cpu(stat, PDF_UTIME, (kernel_uint_t)proc_info->ki_rusage.ru_utime.tv_sec * NSEC_PER_SEC + proc_info->ki_rusage.ru_utime.tv_usec * NSEC_PER_USEC);
pid_incremental_cpu(stat, PDF_STIME, (kernel_uint_t)proc_info->ki_rusage.ru_stime.tv_sec * NSEC_PER_SEC + proc_info->ki_rusage.ru_stime.tv_usec * NSEC_PER_USEC);
pid_incremental_cpu(stat, PDF_CUTIME, (kernel_uint_t)proc_info->ki_rusage_ch.ru_utime.tv_sec * NSEC_PER_SEC + proc_info->ki_rusage_ch.ru_utime.tv_usec * NSEC_PER_USEC);
pid_incremental_cpu(stat, PDF_CSTIME, (kernel_uint_t)proc_info->ki_rusage_ch.ru_stime.tv_sec * NSEC_PER_SEC + proc_info->ki_rusage_ch.ru_stime.tv_usec * NSEC_PER_USEC);

p->values[PDF_THREADS] = proc_info->ki_numthreads;

Expand Down
2 changes: 1 addition & 1 deletion src/collectors/apps.plugin/apps_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define PROCESSES_HAVE_STATE 0
#define PPID_SHOULD_BE_RUNNING 1
#define INCREMENTAL_DATA_COLLECTION 1
#define CPU_TO_NANOSECONDCORES (1000) // convert microseconds to nanoseconds
#define CPU_TO_NANOSECONDCORES (1)
#define OS_FUNCTION(func) OS_FUNC_CONCAT(func, _freebsd)

#elif defined(OS_MACOS)
Expand Down

0 comments on commit 0689f2b

Please sign in to comment.