From 2f5ccd9019ab2ad9532dc7bac1b64b9433bd15a3 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 2 Nov 2004 23:34:01 +0000 Subject: [PATCH] log message if we cant determine idle cpu time --- src/os/win32/win32_sigar.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 00ebe4f2..4626732d 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -361,7 +361,7 @@ static int get_idle_cpu(sigar_t *sigar, sigar_cpu_t *cpu, DWORD retval, num; /* XXX unhardcode 16 */ SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION info[16]; - + /* into the lungs of hell */ sigar->get_ntsys_info(SystemProcessorPerformanceInformation, &info, sizeof(info), &retval); @@ -393,6 +393,7 @@ static int get_idle_cpu(sigar_t *sigar, sigar_cpu_t *cpu, SIGAR_DECLARE(int) sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) { + int status; PERF_INSTANCE_DEFINITION *inst; PERF_COUNTER_BLOCK *counter_block; DWORD perf_offsets[PERF_IX_CPU_MAX], err; @@ -411,10 +412,17 @@ SIGAR_DECLARE(int) sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->sys = PERF_VAL(PERF_IX_CPU_SYS); cpu->user = PERF_VAL(PERF_IX_CPU_USER); - get_idle_cpu(sigar, cpu, -1, counter_block, perf_offsets); + status = get_idle_cpu(sigar, cpu, -1, counter_block, perf_offsets); cpu->nice = 0; /* no nice here */ cpu->total = cpu->sys + cpu->user + cpu->idle; + + if (status != SIGAR_OK) { + sigar_log_printf(sigar, SIGAR_LOG_WARN, + "unable to determine idle cpu time: %s", + sigar_strerror(sigar, status)); + } + return SIGAR_OK; }