diff --git a/bindings/java/src/jni/generate.pl b/bindings/java/src/jni/generate.pl index f8206966..6cb2a9eb 100644 --- a/bindings/java/src/jni/generate.pl +++ b/bindings/java/src/jni/generate.pl @@ -278,6 +278,11 @@ my %classes = ( desc => 'Process cpu kernel time', plat => 'ADHLSW' }, + { + name => 'total', type => 'Long', + desc => 'Process cpu time (sum of User and Sys)', + plat => 'ADHLSW' + }, ], ProcState => [ { diff --git a/bindings/java/src/net/hyperic/sigar/test/TestInvoker.java b/bindings/java/src/net/hyperic/sigar/test/TestInvoker.java index c7945c9a..6bb1a56b 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestInvoker.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestInvoker.java @@ -26,6 +26,7 @@ public class TestInvoker extends SigarTestCase { { "sigar:Type=ProcMem,Arg=$$", "Vsize" }, { "sigar:Type=ProcTime,Arg=$$", "Sys" }, { "sigar:Type=ProcTime,Arg=$$", "User" }, + { "sigar:Type=ProcTime,Arg=$$", "Total" }, //test Utime/Stime backcompat. { "sigar:Type=ProcTime,Arg=$$", "Stime" }, { "sigar:Type=ProcTime,Arg=$$", "Utime" }, diff --git a/include/sigar.h b/include/sigar.h index 4439b34c..2ca8bf48 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -210,7 +210,8 @@ typedef struct { sigar_uint64_t start_time, user, - sys; + sys, + total; } sigar_proc_time_t; SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid, diff --git a/src/os/aix/aix_sigar.c b/src/os/aix/aix_sigar.c index d3416fa3..77c731ff 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -967,6 +967,7 @@ int sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid, proctime->start_time *= 1000; /* convert to ms */ proctime->user = pinfo->pi_utime; proctime->sys = pinfo->pi_stime; + proctime->total = proctime->user + proctime->sys; return SIGAR_OK; } diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 39f90bad..a417010e 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -422,6 +422,7 @@ static int get_proc_times(sigar_pid_t pid, sigar_proc_time_t *time) time->user = utime.seconds; time->sys = stime.seconds; + proctime->total = proctime->user + proctime->sys; return SIGAR_OK; } diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index e18cd389..aec27602 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -297,6 +297,7 @@ int sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid, proctime->start_time *= 1000; proctime->user = pinfo->pst_utime; proctime->sys = pinfo->pst_stime; + proctime->total = proctime->user + proctime->sys; return SIGAR_OK; } diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 0902afc1..8c34c0b1 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -639,6 +639,7 @@ int sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid, proctime->user = pstat->utime; proctime->sys = pstat->stime; + proctime->total = proctime->user + proctime->sys; proctime->start_time = pstat->start_time; return SIGAR_OK; diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index b9a86661..592c7830 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -584,6 +584,7 @@ int sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid, proctime->user = PRTIME_2SIGAR(usage.pr_utime); proctime->sys = PRTIME_2SIGAR(usage.pr_stime); + proctime->total = proctime->user + proctime->sys; return SIGAR_OK; } diff --git a/src/os/stub/stub_sigar.c b/src/os/stub/stub_sigar.c index d96509be..7cc7b32a 100644 --- a/src/os/stub/stub_sigar.c +++ b/src/os/stub/stub_sigar.c @@ -121,6 +121,7 @@ int sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid, proctime->start_time = -1; proctime->user = -1; proctime->sys = -1; + proctime->total = proctime->user + proctime->sys; return SIGAR_OK; } diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 0e24e70a..57634b42 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -647,6 +647,7 @@ SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid, proctime->user = FILETIME2SEC(user_time); proctime->sys = FILETIME2SEC(system_time); + proctime->total = proctime->user + proctime->sys; return SIGAR_OK; }