From 3d4267a6a7656bdcb338796387e352437e5584d1 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 2 Jan 2006 18:45:49 +0000 Subject: [PATCH] workaround freebsd lack of per-cpu metrics --- src/os/darwin/darwin_sigar.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 5aef7d51..d1628599 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -521,14 +521,30 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist) return SIGAR_OK; #else + int status, i; sigar_cpu_t *cpu; sigar_cpu_list_create(cpulist); - /* XXX multi cpu */ + /* XXX howto multi cpu in freebsd? + * for now just report all metrics on the 1st cpu + * 0's for the rest + */ cpu = &cpulist->data[cpulist->number++]; - return sigar_cpu_get(sigar, cpu); + status = sigar_cpu_get(sigar, cpu); + if (status != SIGAR_OK) { + return status; + } + + for (i=1; incpu; i++) { + SIGAR_CPU_LIST_GROW(cpulist); + + cpu = &cpulist->data[cpulist->number++]; + SIGAR_ZERO(cpu); + } + + return SIGAR_OK; #endif }