如何获取以太网通道加载

How to get ethernet channel loading

下午好!与特定问题相关。帮我找决定。


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

要求:获取频道加载速度跨越上传速度。必须每 n 秒进行一次统计(例如,使用模式 "Observer")。结果必须是数字——当前上传的次数 kbit\sec。

问题:我怎么才能达到这个上传速度?也许,在 Java 核心库或外部库中存在方法,可以在当前时刻获得上传速度,或者可以使用其他方法实现?


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

  • netdiag 软件包提供了两个有用的工具来监控网络 : netwatchnetload

    netload会每秒显示所有接收到/ 传输字节和总数。

    用法:netload <interface>

    netwatch 将有助于列出远程主机 传输的数据。

  • speedometer 命令将显示转移的图表 终端上的数据,可以通过apt安装。用法:

    speedometer -r <interface> -t <interface>

  • vnstat 命令将显示实时 TX/RX 等。

    vnstat -l -i <interface>

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.