From 46ba56bc170c3d68e234880749e26c74d0c8c508 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 22 Nov 2004 01:51:34 +0000 Subject: [PATCH] add cpu.wait metric --- bindings/dotnet/src/Sigar.cs | 1 + bindings/java/src/jni/generate.pl | 5 +++++ bindings/java/src/net/hyperic/sigar/test/TestCpu.java | 3 +++ include/sigar.h | 1 + src/os/aix/aix_sigar.c | 6 ++++-- src/os/darwin/darwin_sigar.c | 4 ++-- src/os/hpux/hpux_sigar.c | 2 ++ src/os/linux/linux_sigar.c | 4 ++-- src/os/osf1/osf1_sigar.c | 4 ++-- src/os/solaris/solaris_sigar.c | 2 ++ src/os/stub/stub_sigar.c | 1 + src/os/win32/win32_sigar.c | 4 ++-- 12 files changed, 27 insertions(+), 10 deletions(-) diff --git a/bindings/dotnet/src/Sigar.cs b/bindings/dotnet/src/Sigar.cs index 8cf50eaf..533d85f6 100644 --- a/bindings/dotnet/src/Sigar.cs +++ b/bindings/dotnet/src/Sigar.cs @@ -203,6 +203,7 @@ namespace Hyperic.Sigar { public readonly ulong Sys; private readonly ulong NA_Nice; public readonly ulong Idle; + private readonly ulong NA_Wait; public readonly ulong Total; [DllImport(Sigar.LIBSIGAR)] diff --git a/bindings/java/src/jni/generate.pl b/bindings/java/src/jni/generate.pl index 689a0ff2..92522beb 100644 --- a/bindings/java/src/jni/generate.pl +++ b/bindings/java/src/jni/generate.pl @@ -194,6 +194,11 @@ my %classes = ( desc => 'Total system cpu idle time', plat => '*' }, + { + name => 'wait', type => 'Long', + desc => 'Total system cpu io wait time', + plat => 'ALHS' + }, { name => 'total', type => 'Long', desc => 'Total system cpu time', diff --git a/bindings/java/src/net/hyperic/sigar/test/TestCpu.java b/bindings/java/src/net/hyperic/sigar/test/TestCpu.java index 1d33b2b6..3068229f 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestCpu.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestCpu.java @@ -21,6 +21,9 @@ public class TestCpu extends SigarTestCase { traceln("Idle=" + cpu.getIdle()); assertTrue(cpu.getIdle() >= 0); + traceln("Wait=" + cpu.getWait()); + assertTrue(cpu.getWait() >= 0); + traceln("Total=" + cpu.getTotal()); assertTrue(cpu.getTotal() >= 0); } diff --git a/include/sigar.h b/include/sigar.h index 128e5ded..a0ee2165 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -96,6 +96,7 @@ typedef struct { sys, nice, idle, + wait, total; } sigar_cpu_t; diff --git a/src/os/aix/aix_sigar.c b/src/os/aix/aix_sigar.c index d16e5e9d..cb4e4fb6 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -579,7 +579,8 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->nice = -1; /* N/A */ cpu->sys = cpu_data.sys; cpu->idle = cpu_data.idle; - cpu->total = cpu->user + cpu->sys + cpu->idle + cpu_data.wait; + cpu->wait = cpu_data.wait; + cpu->total = cpu->user + cpu->sys + cpu->idle + cpu->wait; return SIGAR_OK; } } @@ -702,7 +703,8 @@ static int sigar_cpu_list_get_pstat(sigar_t *sigar, sigar_cpu_list_t *cpulist) cpu->nice = -1; /* N/A */ cpu->sys = data.sys; cpu->idle = data.idle; - cpu->total = cpu->user + cpu->sys + cpu->idle + data.wait; + cpu->wait = data.wait; + cpu->total = cpu->user + cpu->sys + cpu->idle + cpu->wait; } else { sigar_log_printf(sigar, SIGAR_LOG_ERROR, diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 1fcaa5f0..9e6b7663 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -220,7 +220,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->sys = cpuload.cpu_ticks[CPU_STATE_SYSTEM]; cpu->idle = cpuload.cpu_ticks[CPU_STATE_IDLE]; cpu->nice = cpuload.cpu_ticks[CPU_STATE_NICE]; - + cpu->wait = 0; /*N/A*/ cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle; #else @@ -229,7 +229,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->nice = 0; cpu->sys = 0; cpu->idle = 0; - + cpu->wait = 0; /*N/A*/ cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle; #endif diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index 4ee5cd60..5dbeecf3 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -98,6 +98,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->sys = stats.psd_cpu_time[CP_SYS] + stats.psd_cpu_time[CP_SSYS]; cpu->nice = stats.psd_cpu_time[CP_NICE]; cpu->idle = stats.psd_cpu_time[CP_IDLE]; + cpu->wait = stats.psd_cpu_time[CP_WAIT]; cpu->total = 0; @@ -136,6 +137,7 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist) cpu->sys = proc.psp_cpu_time[CP_SYS] + proc.psp_cpu_time[CP_SSYS]; cpu->nice = proc.psp_cpu_time[CP_NICE]; cpu->idle = proc.psp_cpu_time[CP_IDLE]; + cpu->wait = proc.psp_cpu_time[CP_WAIT]; cpu->total = 0; diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 9860fb60..72415984 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -292,8 +292,8 @@ static void get_cpu_metrics(sigar_cpu_t *cpu, char *line) cpu->nice += sigar_strtoul(ptr); cpu->sys += sigar_strtoul(ptr); cpu->idle += sigar_strtoul(ptr); - - cpu->total += cpu->user + cpu->nice + cpu->sys + cpu->idle; + cpu->wait = 0; /*XXX*/ + cpu->total += cpu->user + cpu->nice + cpu->sys + cpu->idle + cpu->wait; } int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) diff --git a/src/os/osf1/osf1_sigar.c b/src/os/osf1/osf1_sigar.c index 5073d67a..c15409b1 100644 --- a/src/os/osf1/osf1_sigar.c +++ b/src/os/osf1/osf1_sigar.c @@ -85,8 +85,8 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->nice = sysinfo.si_nice; cpu->sys = sysinfo.si_sys; cpu->idle = sysinfo.si_idle; - - cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle; + cpu->wait = 0; /*N/A?*/ + cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle + cpu->wait; return SIGAR_OK; } diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 3d977386..4b2dbca4 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -291,6 +291,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->sys += xcpu->sys; cpu->idle += xcpu->idle; cpu->nice += xcpu->nice; + cpu->wait += xcpu->wait; cpu->total += xcpu->total; } @@ -358,6 +359,7 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist) cpu->user = cpuinfo[CPU_USER]; cpu->sys = cpuinfo[CPU_KERNEL]; cpu->idle = cpuinfo[CPU_IDLE]; + cpu->wait = cpuinfo[CPU_WAIT]; cpu->nice = 0; /* no cpu->nice */ cpu->total = 0; diff --git a/src/os/stub/stub_sigar.c b/src/os/stub/stub_sigar.c index ffd787a0..58334b68 100644 --- a/src/os/stub/stub_sigar.c +++ b/src/os/stub/stub_sigar.c @@ -48,6 +48,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->nice = -1; cpu->sys = -1; cpu->idle = -1; + cpu->wait = -1; cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle; diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index ac19cf91..848b4210 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -413,8 +413,8 @@ SIGAR_DECLARE(int) sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) cpu->user = PERF_VAL(PERF_IX_CPU_USER); 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; + cpu->wait = 0; /*N/A?*/ + cpu->total = cpu->sys + cpu->user + cpu->idle + cpu->wait; if (status != SIGAR_OK) { sigar_log_printf(sigar, SIGAR_LOG_WARN,