experimenting w/ native net_stat
This commit is contained in:
parent
8091316504
commit
a0de608f82
|
@ -11,6 +11,11 @@ public class NetStat {
|
||||||
private Map tcpOutbound;
|
private Map tcpOutbound;
|
||||||
private int[] tcpStates;
|
private int[] tcpStates;
|
||||||
private int tcpInboundTotal, tcpOutboundTotal;
|
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() {
|
public NetStat() {
|
||||||
this.sigar = new Sigar();
|
this.sigar = new Sigar();
|
||||||
|
@ -23,7 +28,12 @@ public class NetStat {
|
||||||
NetFlags.CONN_SERVER | NetFlags.CONN_CLIENT |
|
NetFlags.CONN_SERVER | NetFlags.CONN_CLIENT |
|
||||||
NetFlags.CONN_TCP;
|
NetFlags.CONN_TCP;
|
||||||
|
|
||||||
stat(flags);
|
if (hasNstat) {
|
||||||
|
nstat(sigar, flags);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stat(flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] newTcpStateArray() {
|
public static int[] newTcpStateArray() {
|
||||||
|
|
Loading…
Reference in New Issue