From a82fbb4cda88c1cd46dbe91e888d9e931829b344 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 4 Mar 2006 07:22:32 +0000 Subject: [PATCH] add OpenFd --- .../src/net/hyperic/sigar/jmx/SigarProcess.java | 15 +++++++++++++++ .../net/hyperic/sigar/jmx/SigarProcessMBean.java | 2 ++ 2 files changed, 17 insertions(+) diff --git a/bindings/java/src/net/hyperic/sigar/jmx/SigarProcess.java b/bindings/java/src/net/hyperic/sigar/jmx/SigarProcess.java index 812f61bc..9efbd559 100644 --- a/bindings/java/src/net/hyperic/sigar/jmx/SigarProcess.java +++ b/bindings/java/src/net/hyperic/sigar/jmx/SigarProcess.java @@ -1,5 +1,6 @@ package net.hyperic.sigar.jmx; +import net.hyperic.sigar.ProcFd; import net.hyperic.sigar.ProcMem; import net.hyperic.sigar.ProcTime; import net.hyperic.sigar.Sigar; @@ -43,6 +44,15 @@ public class SigarProcess implements SigarProcessMBean { throw new IllegalArgumentException(); } } + + private ProcFd getFd() { + try { + long pid = this.sigar.getPid(); + return this.sigar.getProcFd(pid); + } catch (SigarException e) { + throw new IllegalArgumentException(); + } + } public Long getMemSize() { return new Long(getMem().getSize()); @@ -76,6 +86,10 @@ public class SigarProcess implements SigarProcessMBean { return new Long(getTime().getSys()); } + public Long getOpenFd() { + return new Long(getFd().getTotal()); + } + public static void main(String args[]) { SigarProcessMBean proc = new SigarProcess(); System.out.println("MemSize=" + proc.getMemSize()); @@ -84,5 +98,6 @@ public class SigarProcess implements SigarProcessMBean { System.out.println("MemPageFaults=" + proc.getMemPageFaults()); System.out.println("TimeUser=" + proc.getTimeUser()); System.out.println("TimeSys=" + proc.getTimeSys()); + System.out.println("OpenFd=" + proc.getOpenFd()); } } diff --git a/bindings/java/src/net/hyperic/sigar/jmx/SigarProcessMBean.java b/bindings/java/src/net/hyperic/sigar/jmx/SigarProcessMBean.java index 8ea1c6ad..e9283744 100644 --- a/bindings/java/src/net/hyperic/sigar/jmx/SigarProcessMBean.java +++ b/bindings/java/src/net/hyperic/sigar/jmx/SigarProcessMBean.java @@ -24,4 +24,6 @@ public interface SigarProcessMBean { public Long getTimeUser(); public Long getTimeSys(); + + public Long getOpenFd(); }