如何获得以太网通道加载

时间:2017-08-05 09:37:04

标签: linux ubuntu debian ethernet

下午好!结合具体问题。帮我找到决定。

给定:基于Debain的操作系统的ftp-server。有些用户当前正在下载文件。每个连接都有不同的下载速度。最大服务器上传速度 - 100 Mbit \ sec

需要:在上传速度范围内获取频道加载速度。必须每n秒进行一次统计(例如,使用模式“Observer”)。结果必须是数字 - 当前时刻上传kbit \ sec的数量。

问题:我如何才能获得上传速度?也许,Java Core库或外部库中的exists方法,它提供了在当前时刻获得上传速度的机会,或者可以使用另一种方法实现?

可能的决定:只有一个决定,我可以从控制台Linux程序中获取统计信息并解析它。调用程序可以使用方法exec。但是,我发现所有程序都很难解析,因为它们拥有自己的“控制台窗口”并且可以动态工作。我非常想找到更合适的变种。

1 个答案:

答案 0 :(得分:1)

  • The netdiag package provide tow useful tools to monitor the network : netwatch and netload

    The netload will display every second all the Received / Transmitted byte and the total.

    Usage : netload <interface>

    The netwatch will be helpful to list the remote hosts with the transmissed data.

  • The speedometer command will display a graph of the transferred data on the terminal, it can be installed through apt. Usage:

    speedometer -r <interface> -t <interface>

  • the vnstat command will display the real-time TX/RX and more.

    vnstat -l -i <interface>

The man vnstat:

vnStat is a console-based network traffic monitor. It keeps a log of hourly, daily and monthly network traffic for the selected interface(s). However, it isn't a packet sniffer. The traffic information is read from the proc(5) or sys filesystems depending on availability. That way vnStat can be used even without root permissions on most systems.

The implementation is divided into two commands. The purpose of the vnstat command is to provide an interface for querying the traffic information stored in network interface specific databases where as the daemon vnstatd(1) is responsible for data retrieval and storage. Although the daemon process is constantly running as a service, it is actually spending most of the time sleeping between data updates.