add cpu.wait metric

This commit is contained in:
Doug MacEachern 2004-11-22 01:51:34 +00:00
parent 921a4ce41c
commit 46ba56bc17
12 changed files with 27 additions and 10 deletions

View File

@ -203,6 +203,7 @@ namespace Hyperic.Sigar {
public readonly ulong Sys; public readonly ulong Sys;
private readonly ulong NA_Nice; private readonly ulong NA_Nice;
public readonly ulong Idle; public readonly ulong Idle;
private readonly ulong NA_Wait;
public readonly ulong Total; public readonly ulong Total;
[DllImport(Sigar.LIBSIGAR)] [DllImport(Sigar.LIBSIGAR)]

View File

@ -194,6 +194,11 @@ my %classes = (
desc => 'Total system cpu idle time', desc => 'Total system cpu idle time',
plat => '*' plat => '*'
}, },
{
name => 'wait', type => 'Long',
desc => 'Total system cpu io wait time',
plat => 'ALHS'
},
{ {
name => 'total', type => 'Long', name => 'total', type => 'Long',
desc => 'Total system cpu time', desc => 'Total system cpu time',

View File

@ -21,6 +21,9 @@ public class TestCpu extends SigarTestCase {
traceln("Idle=" + cpu.getIdle()); traceln("Idle=" + cpu.getIdle());
assertTrue(cpu.getIdle() >= 0); assertTrue(cpu.getIdle() >= 0);
traceln("Wait=" + cpu.getWait());
assertTrue(cpu.getWait() >= 0);
traceln("Total=" + cpu.getTotal()); traceln("Total=" + cpu.getTotal());
assertTrue(cpu.getTotal() >= 0); assertTrue(cpu.getTotal() >= 0);
} }

View File

@ -96,6 +96,7 @@ typedef struct {
sys, sys,
nice, nice,
idle, idle,
wait,
total; total;
} sigar_cpu_t; } sigar_cpu_t;

View File

@ -579,7 +579,8 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->nice = -1; /* N/A */ cpu->nice = -1; /* N/A */
cpu->sys = cpu_data.sys; cpu->sys = cpu_data.sys;
cpu->idle = cpu_data.idle; 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; 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->nice = -1; /* N/A */
cpu->sys = data.sys; cpu->sys = data.sys;
cpu->idle = data.idle; 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 { else {
sigar_log_printf(sigar, SIGAR_LOG_ERROR, sigar_log_printf(sigar, SIGAR_LOG_ERROR,

View File

@ -220,7 +220,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->sys = cpuload.cpu_ticks[CPU_STATE_SYSTEM]; cpu->sys = cpuload.cpu_ticks[CPU_STATE_SYSTEM];
cpu->idle = cpuload.cpu_ticks[CPU_STATE_IDLE]; cpu->idle = cpuload.cpu_ticks[CPU_STATE_IDLE];
cpu->nice = cpuload.cpu_ticks[CPU_STATE_NICE]; cpu->nice = cpuload.cpu_ticks[CPU_STATE_NICE];
cpu->wait = 0; /*N/A*/
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle; cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;
#else #else
@ -229,7 +229,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->nice = 0; cpu->nice = 0;
cpu->sys = 0; cpu->sys = 0;
cpu->idle = 0; cpu->idle = 0;
cpu->wait = 0; /*N/A*/
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle; cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;
#endif #endif

View File

@ -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->sys = stats.psd_cpu_time[CP_SYS] + stats.psd_cpu_time[CP_SSYS];
cpu->nice = stats.psd_cpu_time[CP_NICE]; cpu->nice = stats.psd_cpu_time[CP_NICE];
cpu->idle = stats.psd_cpu_time[CP_IDLE]; cpu->idle = stats.psd_cpu_time[CP_IDLE];
cpu->wait = stats.psd_cpu_time[CP_WAIT];
cpu->total = 0; 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->sys = proc.psp_cpu_time[CP_SYS] + proc.psp_cpu_time[CP_SSYS];
cpu->nice = proc.psp_cpu_time[CP_NICE]; cpu->nice = proc.psp_cpu_time[CP_NICE];
cpu->idle = proc.psp_cpu_time[CP_IDLE]; cpu->idle = proc.psp_cpu_time[CP_IDLE];
cpu->wait = proc.psp_cpu_time[CP_WAIT];
cpu->total = 0; cpu->total = 0;

View File

@ -292,8 +292,8 @@ static void get_cpu_metrics(sigar_cpu_t *cpu, char *line)
cpu->nice += sigar_strtoul(ptr); cpu->nice += sigar_strtoul(ptr);
cpu->sys += sigar_strtoul(ptr); cpu->sys += sigar_strtoul(ptr);
cpu->idle += sigar_strtoul(ptr); cpu->idle += sigar_strtoul(ptr);
cpu->wait = 0; /*XXX*/
cpu->total += cpu->user + cpu->nice + cpu->sys + cpu->idle; cpu->total += cpu->user + cpu->nice + cpu->sys + cpu->idle + cpu->wait;
} }
int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)

View File

@ -85,8 +85,8 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->nice = sysinfo.si_nice; cpu->nice = sysinfo.si_nice;
cpu->sys = sysinfo.si_sys; cpu->sys = sysinfo.si_sys;
cpu->idle = sysinfo.si_idle; cpu->idle = sysinfo.si_idle;
cpu->wait = 0; /*N/A?*/
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle; cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle + cpu->wait;
return SIGAR_OK; return SIGAR_OK;
} }

View File

@ -291,6 +291,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->sys += xcpu->sys; cpu->sys += xcpu->sys;
cpu->idle += xcpu->idle; cpu->idle += xcpu->idle;
cpu->nice += xcpu->nice; cpu->nice += xcpu->nice;
cpu->wait += xcpu->wait;
cpu->total += xcpu->total; 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->user = cpuinfo[CPU_USER];
cpu->sys = cpuinfo[CPU_KERNEL]; cpu->sys = cpuinfo[CPU_KERNEL];
cpu->idle = cpuinfo[CPU_IDLE]; cpu->idle = cpuinfo[CPU_IDLE];
cpu->wait = cpuinfo[CPU_WAIT];
cpu->nice = 0; /* no cpu->nice */ cpu->nice = 0; /* no cpu->nice */
cpu->total = 0; cpu->total = 0;

View File

@ -48,6 +48,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->nice = -1; cpu->nice = -1;
cpu->sys = -1; cpu->sys = -1;
cpu->idle = -1; cpu->idle = -1;
cpu->wait = -1;
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle; cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;

View File

@ -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); cpu->user = PERF_VAL(PERF_IX_CPU_USER);
status = 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->nice = 0; /* no nice here */
cpu->wait = 0; /*N/A?*/
cpu->total = cpu->sys + cpu->user + cpu->idle; cpu->total = cpu->sys + cpu->user + cpu->idle + cpu->wait;
if (status != SIGAR_OK) { if (status != SIGAR_OK) {
sigar_log_printf(sigar, SIGAR_LOG_WARN, sigar_log_printf(sigar, SIGAR_LOG_WARN,