experimenting w/ native net_stat

This commit is contained in:
Doug MacEachern 2006-06-20 03:14:46 +00:00
parent 8091316504
commit a0de608f82
1 changed files with 12 additions and 2 deletions

View File

@ -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();
@ -23,8 +28,13 @@ public class NetStat {
NetFlags.CONN_SERVER | NetFlags.CONN_CLIENT |
NetFlags.CONN_TCP;
if (hasNstat) {
nstat(sigar, flags);
}
else {
stat(flags);
}
}
public static int[] newTcpStateArray() {
int[] states = new int[NetFlags.TCP_UNKNOWN];