简体   繁体   English

如何在Java中监视特定接口的网络使用情况?

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

我想知道通过特定网络接口传输的确切数据量用于记录目的,是否有任何标准库或api调用,我可以通过这种方式以交叉平台方式执行此操作?

This seems to do what you'd like. 这似乎做你想要的。 At least, I think it will point you in the right direction: http://jnetpcap.com/ 至少,我认为它会指出你正确的方向: 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. 编辑:虽然不是严格的跨平台,libpcap有所有主要平台的库,所以我不认为这是一个显示阻止,但我不是需要它的人。

jNetPcap uses Sigar in some of its unit tests. jNetPcap使用SIGAR在它的一些单元测试。 Sigar advertizes itself as a "portable interface for gathering system information" including network interface detection, configuration info and metrics. Sigar将自己宣传为“用于收集系统信息的便携式接口”,包括网络接口检测,配置信息和指标。 Take a look at its NetInterfaceStat class. 看看它的NetInterfaceStat类。

Note that Sigar also relies on platform specific JNIs, ie Rob H's remark still applies. 请注意,Sigar还依赖于特定于平台的JNI,即Rob H的评论仍然适用。

SNMP4J will let you read the interface mib of any SNMP-compliant device. SNMP4J将允许您读取任何SNMP兼容设备的接口mib Linux and OSX (probably) have an SNMP daemon already running; Linux和OSX(可能)已经运行了一个SNMP守护进程; Windows has an SNMP service that you can install though Programs and Features in Control Panel . Windows具有SNMP服务 ,您可以通过“控制面板”中的“程序和功能”进行安装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM