linux查看使用中的网卡是否打满
程序员文章站
2024-03-13 23:04:17
...
1、查看Linux系统有几块网卡
一般系统默认都有4个,无所谓了管它几个呢~
[root@db25440 ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr D4:BE:D9:AA:30:18
inet addr:10.255.254.40 Bcast:10.255.255.255 Mask:255.255.240.0
inet6 addr: fe80::d6be:d9ff:feaa:3018/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4861130549 errors:0 dropped:0 overruns:0 frame:0
TX packets:5490188631 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1745950525499 (1.5 TiB) TX bytes:2873870867512 (2.6 TiB)
eth1 Link encap:Ethernet HWaddr D4:BE:D9:AA:30:1A
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
eth2 Link encap:Ethernet HWaddr D4:BE:D9:AA:30:1C
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
eth3 Link encap:Ethernet HWaddr D4:BE:D9:AA:30:1E
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:9040433 errors:0 dropped:0 overruns:0 frame:0
TX packets:9040433 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:15560955892 (14.4 GiB) TX bytes:15560955892 (14.4 GiB)
[root@db25440 ~]#
另外可以使用下面两种方式确定
cat /proc/net/dev
lspci | grep -i eth
2、确定网卡的带宽
ethtool命令用于获取以太网卡的配置信息,或者修改这些配置(这个命令比较复杂,功能特别多回头写一个命令解释)
[root@db25440 ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes //自动协商开启 对应关闭配置为:No
Speed: 1000Mb/s //速度 1000Mb
Duplex: Full //全双工 对应配置还有Half
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: g
Wake-on: d
Link detected: yes //eth0已经**
[root@db25440 ~]#
先不用关注每一项的具体含义,先看Advertised link modes、Auto-negotiation、Duplex。首先连接模式、自动协商是否开启(在这里是开启的)、全双工
3、确定目前连接状态和速率
[root@db25440 ~]# mii-tool eth0
eth0: negotiated 100baseTx-FD, link ok
[root@db25440 ~]#
4、根据使用的模式计算支持的最大带宽
网卡传输的计算单位是bit,所以当统计为Byte为单位时就需要转换 1byte=8bit
100Mbits=12.5MB
5、使用工具查看目前网卡上传和下载的使用量比如这里用dstat
root@db25440 ~]# dstat
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
2 0 98 0 0 0|6740B 1257k| 0 0 | 0 60B|1012 2297
0 0 100 0 0 0| 0 0 | 17k 17k| 0 0 | 373 170
0 0 100 0 0 0| 0 0 | 25k 25k| 0 0 | 400 196
0 0 100 0 0 0| 0 0 | 20k 20k| 0 0 | 363 176 ^C
[root@db25440 ~]#
对比就知道网卡是否打满
以上等等 记录备忘
上一篇: Java AES/DES加密&解密