From 11c7fb330b7225211e58a63a99d5fc7837e17a93 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Thu, 12 May 2005 00:50:47 +0000 Subject: [PATCH] convert cpu times to seconds --- src/os/hpux/hpux_sigar.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index eda8125d..10f63a61 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -92,21 +92,22 @@ int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap) return SIGAR_OK; } -static void get_cpu_metrics(sigar_cpu_t *cpu, int32_t *cpu_time) +static void get_cpu_metrics(sigar_t *sigar, + sigar_cpu_t *cpu, int32_t *cpu_time) { int i; - cpu->user = cpu_time[CP_USER]; - cpu->sys = cpu_time[CP_SYS] + cpu_time[CP_SSYS]; - cpu->nice = cpu_time[CP_NICE]; - cpu->idle = cpu_time[CP_IDLE]; - cpu->wait = cpu_time[CP_WAIT]; + cpu->user = SIGAR_TICK2SEC(cpu_time[CP_USER]); + cpu->sys = SIGAR_TICK2SEC(cpu_time[CP_SYS] + cpu_time[CP_SSYS]); + cpu->nice = SIGAR_TICK2SEC(cpu_time[CP_NICE]); + cpu->idle = SIGAR_TICK2SEC(cpu_time[CP_IDLE]); + cpu->wait = SIGAR_TICK2SEC(cpu_time[CP_WAIT]); cpu->total = 0; /* states above plus CP_BLOCK, CP_SWAIT, etc. (see sys/dk.h) */ for (i=0; itotal += cpu_time[i]; + cpu->total += SIGAR_TICK2SEC(cpu_time[i]); } } @@ -117,7 +118,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) pstat_getdynamic(&stats, sizeof(stats), 1, 0); sigar->ncpu = stats.psd_proc_cnt; - get_cpu_metrics(cpu, stats.psd_cpu_time); + get_cpu_metrics(sigar, cpu, stats.psd_cpu_time); return SIGAR_OK; } @@ -144,7 +145,7 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist) cpu = &cpulist->data[cpulist->number++]; - get_cpu_metrics(cpu, proc.psp_cpu_time); + get_cpu_metrics(sigar, cpu, proc.psp_cpu_time); } return SIGAR_OK;