我想获取 TX 和 RX 的总量,以了解服务器某一时刻正在接收或发送的数据量。
通过这个命令ip -s link我得到这个结果
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
RX: bytes packets errors dropped overrun mcast
21914963679042 3114955121 0 0 0 0
TX: bytes packets errors dropped carrier collsns
21914963679042 3114955121 0 0 0 0
2: enp3s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether d4:5d:64:40:53:ca brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun …Run Code Online (Sandbox Code Playgroud) 我使用此命令从命名管道读取连续数据:
{ while :; do dd iflag=fullblock iflag=nonblock bs=65536 count=1 2> /dev/null | redis-cli -x PUBLISH myChannel ; done } < myFifo
Run Code Online (Sandbox Code Playgroud)
问题是,即使我同时运行 50 个命令,CPU 使用率也会很高。该过程应该是长时间运行的,并且其中许多过程应该同时工作。
那么,其原因是什么以及如何预防呢?谢谢。