diff --git a/bindings/java/src/org/hyperic/sigar/test/TestCpuInfo.java b/bindings/java/src/org/hyperic/sigar/test/TestCpuInfo.java index 7e7d42b2..73ef8f0d 100644 --- a/bindings/java/src/org/hyperic/sigar/test/TestCpuInfo.java +++ b/bindings/java/src/org/hyperic/sigar/test/TestCpuInfo.java @@ -40,6 +40,7 @@ public class TestCpuInfo extends SigarTestCase { traceln("model=" + info.getModel()); traceln("mhz=" + info.getMhz()); traceln("cache size=" + info.getCacheSize()); + assertTrue(info.getTotalSockets() <= info.getTotalCores()); } int mhz = infos[0].getMhz(); diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 304bb2fe..e51b214f 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -1700,6 +1700,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar, int brand = -1; sigar_cache_t *chips; int is_debug = SIGAR_LOG_IS_DEBUG(sigar); + int nsockets = 0; if (sigar_kstat_update(sigar) == -1) { /* for sigar->ncpu */ return errno; @@ -1739,9 +1740,12 @@ int sigar_cpu_info_list_get(sigar_t *sigar, sigar_cache_get(chips, chip_id); if (ent->value) { - continue; + if (!sigar->cpu_list_cores) { + continue; + } } else { + ++nsockets; ent->value = chips; /*anything non-NULL*/ if (is_debug) { sigar_log_printf(sigar, SIGAR_LOG_DEBUG, @@ -1751,6 +1755,9 @@ int sigar_cpu_info_list_get(sigar_t *sigar, } } } + else { + ++nsockets; + } SIGAR_CPU_INFO_LIST_GROW(cpu_infos); @@ -1788,6 +1795,12 @@ int sigar_cpu_info_list_get(sigar_t *sigar, sigar_cache_destroy(chips); + for (i=0; inumber; i++) { + sigar_cpu_info_t *info = &cpu_infos->data[i]; + info->total_sockets = nsockets; + info->total_cores = sigar->ncpu; + } + return SIGAR_OK; }