Get the network traffic in bytes

I try to get the number of bytes to pass by the network interface.

The code I use is:

String [] interfaceList = this.proxy.getNetInterfaceList ();
a long time in = 0L;
long out = 0L;

for (String inteface: interfaceList) {}
log. Debug (inteface);
NetInterfaceStat netsstat = this.proxy.getNetInterfaceStat (inteface);
in += netsstat.getRxBytes ();
on += netsstat.getTxBytes ();
}

I'm not sure that I do it well, because the figures are not updated often. For example, I download a movie from youTube and the number does not change. I have to wait 30 seconds before it changes. Is the resolution of a minimum amount of time (on Windows 2000 Pro) is 30 seconds?

Hi James,

I saw this.proxy in your code, guess that is an instance of SigarProxyCache?  This class is a wrapper for caching the values returned by the underlying class of Sigar, 30 seconds by default.  You can change this value by default, but it seems you'd be better of just using the new Sigar() straight-up instead of the ProxyCache.

Tags: VMware

Similar Questions

Maybe you are looking for