From a0de608f822049ab633a42f7cd0bb63dc99f616c Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 20 Jun 2006 03:14:46 +0000 Subject: [PATCH] experimenting w/ native net_stat --- bindings/java/src/net/hyperic/sigar/NetStat.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bindings/java/src/net/hyperic/sigar/NetStat.java b/bindings/java/src/net/hyperic/sigar/NetStat.java index a082530a..99e2b14b 100644 --- a/bindings/java/src/net/hyperic/sigar/NetStat.java +++ b/bindings/java/src/net/hyperic/sigar/NetStat.java @@ -11,6 +11,11 @@ public class NetStat { private Map tcpOutbound; private int[] tcpStates; private int tcpInboundTotal, tcpOutboundTotal; + //XXX not implemented on all platforms yet + private static final boolean hasNstat = + "true".equals(System.getProperty("sigar.netstat.native")); + + private native void nstat(Sigar sigar, int flags) throws SigarException; public NetStat() { this.sigar = new Sigar(); @@ -22,8 +27,13 @@ public class NetStat { int flags = NetFlags.CONN_SERVER | NetFlags.CONN_CLIENT | NetFlags.CONN_TCP; - - stat(flags); + + if (hasNstat) { + nstat(sigar, flags); + } + else { + stat(flags); + } } public static int[] newTcpStateArray() {