From c0bd0b183098cfd327b21d7ddf8cea04061193ab Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sun, 25 May 2008 01:45:02 +0000 Subject: [PATCH] add cpu.irq for windows --- bindings/SigarWrapper.pm | 4 ++-- bindings/java/src/org/hyperic/sigar/cmd/CpuInfo.java | 2 +- src/os/win32/sigar_os.h | 5 +++-- src/os/win32/win32_sigar.c | 12 ++++++++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/bindings/SigarWrapper.pm b/bindings/SigarWrapper.pm index 99cb9ad2..00dc9fea 100644 --- a/bindings/SigarWrapper.pm +++ b/bindings/SigarWrapper.pm @@ -445,7 +445,7 @@ use vars qw(%classes %cmds); { name => 'irq', type => 'Long', desc => 'Total system cpu time servicing interrupts', - plat => 'FLH' + plat => 'FLHW' }, { name => 'soft_irq', type => 'Long', @@ -492,7 +492,7 @@ use vars qw(%classes %cmds); { name => 'irq', type => 'Double', desc => 'Percent system cpu time servicing interrupts', - plat => 'FLH' + plat => 'FLHW' }, { name => 'soft_irq', type => 'Double', diff --git a/bindings/java/src/org/hyperic/sigar/cmd/CpuInfo.java b/bindings/java/src/org/hyperic/sigar/cmd/CpuInfo.java index 3a631a74..36c6bf3d 100644 --- a/bindings/java/src/org/hyperic/sigar/cmd/CpuInfo.java +++ b/bindings/java/src/org/hyperic/sigar/cmd/CpuInfo.java @@ -49,8 +49,8 @@ public class CpuInfo extends SigarCommandBase { println("Wait Time....." + CpuPerc.format(cpu.getWait())); println("Nice Time....." + CpuPerc.format(cpu.getNice())); println("Combined......" + CpuPerc.format(cpu.getCombined())); + println("Irq Time......" + CpuPerc.format(cpu.getIrq())); if (SigarLoader.IS_LINUX) { - println("Irq Time......" + CpuPerc.format(cpu.getIrq())); println("SoftIrq Time.." + CpuPerc.format(cpu.getSoftIrq())); println("Steal Time...." + CpuPerc.format(cpu.getSteal())); } diff --git a/src/os/win32/sigar_os.h b/src/os/win32/sigar_os.h index 17cc3997..c5555a5a 100644 --- a/src/os/win32/sigar_os.h +++ b/src/os/win32/sigar_os.h @@ -221,8 +221,9 @@ typedef struct { LARGE_INTEGER IdleTime; LARGE_INTEGER KernelTime; LARGE_INTEGER UserTime; - LARGE_INTEGER Reserved1[2]; - ULONG Reserved2; + LARGE_INTEGER DpcTime; + LARGE_INTEGER InterruptTime; + ULONG InterruptCount; } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION; #define SystemProcessorPerformanceInformation 8 diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 6fe53c89..34ac3c20 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -37,11 +37,13 @@ #define PERF_TITLE_CPU_USER 142 #define PERF_TITLE_CPU_IDLE 1746 #define PERF_TITLE_CPU_SYS 144 +#define PERF_TITLE_CPU_IRQ 698 typedef enum { PERF_IX_CPU_USER, PERF_IX_CPU_IDLE, PERF_IX_CPU_SYS, + PERF_IX_CPU_IRQ, PERF_IX_CPU_MAX } perf_cpu_offsets_t; @@ -698,6 +700,9 @@ static PERF_INSTANCE_DEFINITION *get_cpu_instance(sigar_t *sigar, case PERF_TITLE_CPU_IDLE: perf_offsets[PERF_IX_CPU_IDLE] = offset; break; + case PERF_TITLE_CPU_IRQ: + perf_offsets[PERF_IX_CPU_IRQ] = offset; + break; } } @@ -780,9 +785,10 @@ static int sigar_cpu_perflib_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->sys = PERF_VAL_CPU(PERF_IX_CPU_SYS); cpu->user = PERF_VAL_CPU(PERF_IX_CPU_USER); status = get_idle_cpu(sigar, cpu, -1, counter_block, perf_offsets); + cpu->irq = PERF_VAL_CPU(PERF_IX_CPU_IRQ); cpu->nice = 0; /* no nice here */ cpu->wait = 0; /*N/A?*/ - cpu->total = cpu->sys + cpu->user + cpu->idle + cpu->wait; + cpu->total = cpu->sys + cpu->user + cpu->idle + cpu->wait + cpu->irq; if (status != SIGAR_OK) { sigar_log_printf(sigar, SIGAR_LOG_WARN, @@ -814,6 +820,7 @@ static int sigar_cpu_ntsys_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->user += NS100_2MSEC(info[i].UserTime.QuadPart); cpu->sys += NS100_2MSEC(info[i].KernelTime.QuadPart - info[i].IdleTime.QuadPart); + cpu->irq += NS100_2MSEC(info[i].InterruptTime.QuadPart); cpu->total += cpu->idle + cpu->user + cpu->sys; } @@ -879,11 +886,12 @@ static int sigar_cpu_list_perflib_get(sigar_t *sigar, cpu->sys += PERF_VAL_CPU(PERF_IX_CPU_SYS); cpu->user += PERF_VAL_CPU(PERF_IX_CPU_USER); + cpu->irq += PERF_VAL_CPU(PERF_IX_CPU_IRQ); get_idle_cpu(sigar, cpu, i, counter_block, perf_offsets); cpu->nice = cpu->wait = 0; /*N/A*/ /*XXX adding up too much here if xeon, but not using this atm*/ - cpu->total += cpu->sys + cpu->user + cpu->idle; + cpu->total += cpu->sys + cpu->user + cpu->idle + cpu->irq; inst = PdhNextInstance(inst); }