开发者

How to monitor the Network usage of a particular interface in Java?

I want to know the exact amount of data which is getting transferred through a particular network interface for logging purpose, is there any standard开发者_如何转开发 library or api call from which I can do this in a cross platfrom way?


This seems to do what you'd like. At least, I think it will point you in the right direction: http://jnetpcap.com/

edit: While not strictly cross-platform, libpcap has libraries for all major platforms so I wouldn't consider that a show-stopper, but I'm not the one that needs it.


jNetPcap uses Sigar in some of its unit tests. Sigar advertizes itself as a "portable interface for gathering system information" including network interface detection, configuration info and metrics. Take a look at its NetInterfaceStat class.

Note that Sigar also relies on platform specific JNIs, i.e. Rob H's remark still applies.


SNMP4J will let you read the interface mib of any SNMP-compliant device. Linux and OSX (probably) have an SNMP daemon already running; Windows has an SNMP service that you can install though Programs and Features in Control Panel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜