且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用PHP获取Linux中当前的带宽使用情况

更新时间:2023-01-27 13:16:50

如果guest虚拟机也正在运行Linux,或者它们在主机上具有单独的接口,则可以使用/sys/class/net/$ interface_name/statistics/rx_bytes和tx_bytes,只需比较差异并除以时间即可得出当前吞吐量的估算值.

If the guests are also running Linux or they have separate interfaces on the host, you can cat /sys/class/net/$interface_name/statistics/rx_bytes and tx_bytes, just compare the difference and divide by time to get an estimate of current throughput.