add OpenFd

This commit is contained in:
Doug MacEachern 2006-03-04 07:22:32 +00:00
parent fa5bea7363
commit a82fbb4cda
2 changed files with 17 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package net.hyperic.sigar.jmx; package net.hyperic.sigar.jmx;
import net.hyperic.sigar.ProcFd;
import net.hyperic.sigar.ProcMem; import net.hyperic.sigar.ProcMem;
import net.hyperic.sigar.ProcTime; import net.hyperic.sigar.ProcTime;
import net.hyperic.sigar.Sigar; import net.hyperic.sigar.Sigar;
@ -44,6 +45,15 @@ public class SigarProcess implements SigarProcessMBean {
} }
} }
private ProcFd getFd() {
try {
long pid = this.sigar.getPid();
return this.sigar.getProcFd(pid);
} catch (SigarException e) {
throw new IllegalArgumentException();
}
}
public Long getMemSize() { public Long getMemSize() {
return new Long(getMem().getSize()); return new Long(getMem().getSize());
} }
@ -76,6 +86,10 @@ public class SigarProcess implements SigarProcessMBean {
return new Long(getTime().getSys()); return new Long(getTime().getSys());
} }
public Long getOpenFd() {
return new Long(getFd().getTotal());
}
public static void main(String args[]) { public static void main(String args[]) {
SigarProcessMBean proc = new SigarProcess(); SigarProcessMBean proc = new SigarProcess();
System.out.println("MemSize=" + proc.getMemSize()); System.out.println("MemSize=" + proc.getMemSize());
@ -84,5 +98,6 @@ public class SigarProcess implements SigarProcessMBean {
System.out.println("MemPageFaults=" + proc.getMemPageFaults()); System.out.println("MemPageFaults=" + proc.getMemPageFaults());
System.out.println("TimeUser=" + proc.getTimeUser()); System.out.println("TimeUser=" + proc.getTimeUser());
System.out.println("TimeSys=" + proc.getTimeSys()); System.out.println("TimeSys=" + proc.getTimeSys());
System.out.println("OpenFd=" + proc.getOpenFd());
} }
} }

View File

@ -24,4 +24,6 @@ public interface SigarProcessMBean {
public Long getTimeUser(); public Long getTimeUser();
public Long getTimeSys(); public Long getTimeSys();
public Long getOpenFd();
} }