diff options
Diffstat (limited to 'src/libvmon')
-rw-r--r-- | src/libvmon/vmon.c | 3 | ||||
-rw-r--r-- | src/libvmon/vmon.h | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/libvmon/vmon.c b/src/libvmon/vmon.c index a8e2121..2815d2e 100644 --- a/src/libvmon/vmon.c +++ b/src/libvmon/vmon.c @@ -1011,6 +1011,9 @@ int vmon_init(vmon_t *vmon, vmon_flags_t flags, vmon_sys_wants_t sys_wants, vmon vmon->sys_wants = sys_wants; vmon->proc_wants = proc_wants; vmon->ticks_per_sec = sysconf(_SC_CLK_TCK); + vmon->num_cpus = sysconf(_SC_NPROCESSORS_ONLN); + if (vmon->num_cpus <= 0) + vmon->num_cpus = 1; /* default to 1 cpu */ /* here we populate the sys and proc function tables */ #define vmon_want(_sym, _name, _func) \ diff --git a/src/libvmon/vmon.h b/src/libvmon/vmon.h index cf282b0..6668605 100644 --- a/src/libvmon/vmon.h +++ b/src/libvmon/vmon.h @@ -277,6 +277,7 @@ typedef struct _vmon_t { vmon_sys_wants_t sys_wants; /* system-wide wants mask */ vmon_proc_wants_t proc_wants; /* inherited per-process wants mask */ long ticks_per_sec; /* sysconf(_SC_CLK_TCK) */ + long num_cpus; /* sysconf(_SC_NPROCESSORS_ONLN) */ /* function tables for mapping of wants bits to functions (sys-wide and per-process) */ int (*sys_funcs[VMON_STORE_SYS_NR])(struct _vmon_t *, void **); |