[SIGAR-71] option for cpu_list to report cores rather than sockets

This commit is contained in:
Doug MacEachern 2007-11-06 06:55:55 +00:00
parent 9955d435de
commit ac8f9541cd
5 changed files with 14 additions and 7 deletions

View File

@ -55,9 +55,10 @@ public class CpuInfo extends SigarCommandBase {
org.hyperic.sigar.CpuInfo[] infos = org.hyperic.sigar.CpuInfo[] infos =
this.sigar.getCpuInfoList(); this.sigar.getCpuInfoList();
CpuPerc[] cpus = null; CpuPerc[] cpus =
this.sigar.getCpuPercList();
println(infos.length + " total CPUs.."); println(cpus.length + " total CPUs..");
org.hyperic.sigar.CpuInfo info = infos[0]; org.hyperic.sigar.CpuInfo info = infos[0];
long cacheSize = info.getCacheSize(); long cacheSize = info.getCacheSize();
println("Vendor........" + info.getVendor()); println("Vendor........" + info.getVendor());
@ -72,11 +73,8 @@ public class CpuInfo extends SigarCommandBase {
return; return;
} }
for (int i=0; i<infos.length; i++) { for (int i=0; i<cpus.length; i++) {
println("CPU " + i + "........."); println("CPU " + i + ".........");
if (cpus == null) {
cpus = this.sigar.getCpuPercList();
}
output(cpus[i]); output(cpus[i]);
} }

View File

@ -48,6 +48,7 @@
* feel free trav ;-) * feel free trav ;-)
*/ */
#define SIGAR_T_BASE \ #define SIGAR_T_BASE \
int cpu_list_cores; \
int log_level; \ int log_level; \
void *log_data; \ void *log_data; \
sigar_log_impl_t log_impl; \ sigar_log_impl_t log_impl; \

View File

@ -248,6 +248,12 @@ static int is_ht_enabled(sigar_t *sigar)
sigar->ht_enabled = 0; sigar->ht_enabled = 0;
sigar->lcpu = 0; sigar->lcpu = 0;
if (sigar->cpu_list_cores) {
sigar_log_printf(sigar, SIGAR_LOG_DEBUG,
"[cpu] skipping HT check");
return 0;
}
sigar_cpuid(0, &eax, &ebx, &ecx, &edx); sigar_cpuid(0, &eax, &ebx, &ecx, &edx);
if ((ebx == INTEL_ID) || (ebx == AMD_ID)) { if ((ebx == INTEL_ID) || (ebx == AMD_ID)) {

View File

@ -438,7 +438,7 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
buf = ksp->ks_data; buf = ksp->ks_data;
buf += sizeof(kmutex_t); buf += sizeof(kmutex_t);
memcpy(&cpuinfo[0], buf, sizeof(cpuinfo)); memcpy(&cpuinfo[0], buf, sizeof(cpuinfo));
chip_id = get_chip_id(sigar, i); chip_id = sigar->cpu_list_cores ? -1 : get_chip_id(sigar, i);
if (chip_id == -1) { if (chip_id == -1) {
SIGAR_CPU_LIST_GROW(cpulist); SIGAR_CPU_LIST_GROW(cpulist);

View File

@ -39,6 +39,8 @@ SIGAR_DECLARE(int) sigar_open(sigar_t **sigar)
int status = sigar_os_open(sigar); int status = sigar_os_open(sigar);
if (status == SIGAR_OK) { if (status == SIGAR_OK) {
/* XXX tmp hack */
(*sigar)->cpu_list_cores = getenv("SIGAR_CPU_CORES") ? 1 : 0;
(*sigar)->pid = 0; (*sigar)->pid = 0;
(*sigar)->ifconf_buf = NULL; (*sigar)->ifconf_buf = NULL;
(*sigar)->ifconf_len = 0; (*sigar)->ifconf_len = 0;