diff --git a/bindings/java/src/jni/generate.pl b/bindings/java/src/jni/generate.pl index 00a86952..118d147f 100644 --- a/bindings/java/src/jni/generate.pl +++ b/bindings/java/src/jni/generate.pl @@ -260,6 +260,21 @@ my %classes = ( desc => 'Process resident set size', plat => '*' }, + { + name => 'minor_faults', type => 'Long', + desc => '', + plat => '' + }, + { + name => 'major_faults', type => 'Long', + desc => '', + plat => '' + }, + { + name => 'page_faults', type => 'Long', + desc => '', + plat => '' + }, ], ProcCred => [ { diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcMem.java b/bindings/java/src/net/hyperic/sigar/test/TestProcMem.java index addd4b10..7bebf846 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcMem.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcMem.java @@ -26,6 +26,9 @@ public class TestProcMem extends SigarTestCase { traceln("Resident=" + Sigar.formatSize(procMem.getResident())); traceln("Share=" + Sigar.formatSize(procMem.getShare())); traceln("Rss=" + Sigar.formatSize(procMem.getRss())); + traceln("MinorFaults=" + procMem.getMinorFaults()); + traceln("MajorFaults=" + procMem.getMajorFaults()); + traceln("PageFaults=" + procMem.getPageFaults()); //assertTrue(procMem.getSize() > 0); // XXX vsize, resident, share, rss } diff --git a/include/sigar.h b/include/sigar.h index 08f8283f..d377d5f4 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -208,7 +208,10 @@ typedef struct { vsize, resident, share, - rss; + rss, + minor_faults, + major_faults, + page_faults; } sigar_proc_mem_t; SIGAR_DECLARE(int) sigar_proc_mem_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 07b4392f..cf70ca47 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -1090,6 +1090,12 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, procmem->rss = PAGESHIFT(pinfo->pi_drss + pinfo->pi_trss); procmem->resident = procmem->rss; + procmem->minor_faults = pinfo->pi_minflt; + procmem->major_faults = pinfo->pi_majflt; + procmem->page_faults = + procmem->minor_faults + + procmem->major_faults; + return SIGAR_OK; } diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index 30eceb75..baccd60f 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -275,6 +275,12 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, procmem->share = pinfo->pst_shmsize * pagesize; + procmem->minor_faults = pinfo->pst_minorfaults; + procmem->major_faults = pinfo->pst_majorfaults; + procmem->page_faults = + procmem->minor_faults + + procmem->major_faults; + return SIGAR_OK; } diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index fd11c497..a9c0693b 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -602,9 +602,9 @@ static int proc_stat_read(sigar_t *sigar, sigar_pid_t pid) ptr = sigar_skip_token(ptr); /* tty pgrp */ ptr = sigar_skip_token(ptr); /* flags */ - ptr = sigar_skip_token(ptr); /* min flt */ + pstat->minor_faults = sigar_strtoul(ptr); ptr = sigar_skip_token(ptr); /* cmin flt */ - ptr = sigar_skip_token(ptr); /* maj flt */ + pstat->major_faults = sigar_strtoul(ptr); ptr = sigar_skip_token(ptr); /* cmaj flt */ pstat->utime = sigar_strtoul(ptr) / sigar->ticks; @@ -656,7 +656,11 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, procmem->vsize = pstat->vsize; procmem->rss = pstat->rss; - + procmem->minor_faults = pstat->minor_faults; + procmem->major_faults = pstat->major_faults; + procmem->page_faults = + procmem->minor_faults + procmem->major_faults; + status = SIGAR_PROC_FILE2STR(buffer, pid, "/statm"); if (status != SIGAR_OK) { diff --git a/src/os/linux/sigar_os.h b/src/os/linux/sigar_os.h index 737f95a0..3dcad243 100644 --- a/src/os/linux/sigar_os.h +++ b/src/os/linux/sigar_os.h @@ -19,6 +19,8 @@ typedef struct { time_t mtime; sigar_uint64_t vsize; sigar_uint64_t rss; + sigar_uint64_t minor_faults; + sigar_uint64_t major_faults; sigar_uint64_t ppid; int tty; int priority; diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index f345b49e..a471a90e 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -575,6 +575,7 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, { int status = sigar_proc_psinfo_get(sigar, pid); psinfo_t *pinfo = sigar->pinfo; + prusage_t usage; if (status != SIGAR_OK) { return status; @@ -586,6 +587,19 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, procmem->vsize = SIGAR_FIELD_NOTIMPL; procmem->share = SIGAR_FIELD_NOTIMPL; + if (sigar_proc_usage_get(sigar, &usage, pid) == SIGAR_OK) { + procmem->minor_faults = usage.pr_minf; + procmem->major_faults = usage.pr_majf; + procmem->page_faults = + procmem->minor_faults + + procmem->major_faults; + } + else { + procmem->minor_faults = SIGAR_FIELD_NOTIMPL; + procmem->major_faults = SIGAR_FIELD_NOTIMPL; + procmem->page_faults = SIGAR_FIELD_NOTIMPL; + } + return SIGAR_OK; }