NT does not have a Processor _Total perf counter instance

This commit is contained in:
Doug MacEachern 2004-06-23 05:21:13 +00:00
parent 263b68ba53
commit f0b267957a
1 changed files with 8 additions and 2 deletions

View File

@ -347,12 +347,17 @@ SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
/* first instance is total, rest are per-cpu */ /* first instance is total, rest are per-cpu */
inst = get_cpu_instance(sigar, (DWORD*)&perf_offsets, &num, &err); inst = get_cpu_instance(sigar, (DWORD*)&perf_offsets, &num, &err);
--num;
if (!inst) { if (!inst) {
return err; return err;
} }
if (!sigar->winnt) {
/* skip Processor _Total instance (NT doesnt have one) */
--num;
inst = PdhNextInstance(inst);
}
sigar_cpu_count(sigar); sigar_cpu_count(sigar);
sigar_cpu_list_create(cpulist); sigar_cpu_list_create(cpulist);
@ -380,7 +385,6 @@ SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
SIGAR_ZERO(cpu); SIGAR_ZERO(cpu);
} }
inst = PdhNextInstance(inst);
counter_block = PdhGetCounterBlock(inst); counter_block = PdhGetCounterBlock(inst);
cpu->sys += PERF_VAL(PERF_IX_CPU_SYS); cpu->sys += PERF_VAL(PERF_IX_CPU_SYS);
@ -389,6 +393,8 @@ SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
cpu->nice = 0; /* no nice here */ cpu->nice = 0; /* no nice here */
cpu->total += cpu->sys + cpu->user + cpu->idle; cpu->total += cpu->sys + cpu->user + cpu->idle;
inst = PdhNextInstance(inst);
} }
return SIGAR_OK; return SIGAR_OK;