我需要找出我的服务器总共有多少个物理端口,其中有多少正在使用,有多少空闲。您能帮我找到它吗:
这是我从 dmidecode 输出中发现的:
# dmidecode | egrep -i "PCI|Available|in use"
PCI is supported
ESCD support is available
Designation: PCI-E Slot 1
Type: x8 PCI Express
Current Usage: In Use
Designation: PCI-E Slot 2
Type: x8 PCI Express
Current Usage: Available
Designation: PCI-E Slot 3
Type: x4 PCI Express
Current Usage: Available
Designation: PCI-E Slot 4
Type: x8 PCI Express
Current Usage: In Use
Designation: PCI-E Slot 5
Type: x8 PCI Express
Current Usage: In Use
# dmidecode | grep -i "NIC"
HP BIOS NIC PCI and MAC Information
NIC 1: PCI device 04:00.0, MAC address 00:1E:0B:C0:F4:92
NIC 2: PCI device 42:00.0, MAC address 00:1E:0B:C0:F4:90
HP BIOS iSCSI NIC PCI and MAC Information
NIC 1: PCI device 04:00.0, MAC address 00:1E:0B:C0:F4:93
NIC 2: PCI device 42:00.0, MAC address 00:1E:0B:C0:F4:91
[root@eir1 network-scripts]# cat ifcfg-eth[0123] | grep -i HWADDR
HWADDR=00:1E:0B:C0:F4:92
HWADDR=00:1E:0B:C0:F4:90
HWADDR=00:26:55:e6:75:5c
HWADDR=00:26:55:e6:75:5d
我如何从中得出结论,有多少物理端口正在使用中,有多少可用?请帮忙
答案1
这是您需要做的。
首先列出所有网卡端口,每行一个端口。
-bash-4.1# lspci | grep -i ethernet
03:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
03:00.1 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
04:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
04:00.1 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
08:00.0 Ethernet controller: Solarflare Communications SFC9120 (rev 01)
08:00.1 Ethernet controller: Solarflare Communications SFC9120 (rev 01)
0b:00.0 Ethernet controller: Solarflare Communications SFC9020 [Solarstorm]
0b:00.1 Ethernet controller: Solarflare Communications SFC9020 [Solarstorm]
0e:00.0 Ethernet controller: Intel Corporation 82580 Gigabit Network Connection (rev 01)
0e:00.1 Ethernet controller: Intel Corporation 82580 Gigabit Network Connection (rev 01)
0e:00.2 Ethernet controller: Intel Corporation 82580 Gigabit Network Connection (rev 01)
0e:00.3 Ethernet controller: Intel Corporation 82580 Gigabit Network Connection (rev 01)
11:00.0 Ethernet controller: Solarflare Communications SFC9120 (rev 01)
11:00.1 Ethernet controller: Solarflare Communications SFC9120 (rev 01)
我如何知道哪个端口是哪个 NIC 接口?(例如,eth0)
-bash-4.1# ethtool -i eth0
driver: sfc
version: 4.1.2.1003b
firmware-version: 4.2.2.1003 rx1 tx1
bus-info: 0000:08:00.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no
现在您可以看到bus-info: 0000:08:00.0
比赛了08:00.0 Ethernet controller: Solarflare Communications SFC9120 (rev 01)
。
驱动程序名称也是一种快速识别的方法,在本例中sfc
表示“Solarflare Communications”
因此,eth0
Solarflare 端口之一很容易检查它是否已启动
ip link show eth0
现在您将能够了解您有多少个 NIC 端口,以及每张卡上有多少个可用端口。
谢谢
答案2
您可以尝试/sbin/ifconfig -a
或ip link show
进一步尝试ethtool
。
后者显示连接状态。
答案3
我不太清楚你的意思物理端口。解码可以列出连接器,
# dmidecode --type 8
# dmidecode 2.12
SMBIOS 2.5 present.
Handle 0x0004, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator:
Internal Connector Type: None
External Reference Designator: EXTERNAL MONITOR PORT
External Connector Type: DB-15 female
Port Type: Other
Handle 0x0005, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator:
Internal Connector Type: None
External Reference Designator: BUILT-IN LAN PORT
External Connector Type: RJ-45
Port Type: Network Port
Handle 0x0006, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator:
Internal Connector Type: None
External Reference Designator: USB PORT
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x0007, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator:
Internal Connector Type: None
External Reference Designator: USB PORT
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x0008, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator:
Internal Connector Type: None
External Reference Designator: USB/eSATA PORT
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x0009, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator:
Internal Connector Type: None
External Reference Designator: HEADPHONE JACK
External Connector Type: Mini Jack (headphones)
Port Type: Other
Handle 0x000A, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator:
Internal Connector Type: None
External Reference Designator: HDMI-CONNECTOR
External Connector Type: Other
Port Type: Video Port
Handle 0x000B, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator:
Internal Connector Type: None
External Reference Designator: MICROPHONE JACK
External Connector Type: Other
Port Type: Other
或系统插槽,
# dmidecode --type 9
# dmidecode 2.12
SMBIOS 2.5 present.
Handle 0x000C, DMI type 9, 13 bytes
System Slot Information
Designation: SD CARD
Type: Other
Current Usage: In Use
Length: Other
Characteristics:
3.3 V is provided
Hot-plug devices are supported
Handle 0x000D, DMI type 9, 13 bytes
System Slot Information
Designation: EXPRESS CARD
Type: x1 PCI Express
Current Usage: In Use
Length: Other
ID: 1
Characteristics:
3.3 V is provided
Hot-plug devices are supported
您还需要什么?您可以找到所有相关代码在 dmidecode 的 sourceforge 页面上
答案4
要将卡/端口与特定的接口名称关联起来,以下命令也很方便。
/sys/class/net 中的链接具有可以将端口映射到接口名称的总线号。
root@xxx:~# ls -l /sys/class/net/
total 0
lrwxrwxrwx 1 root root 0 Aug 7 16:51 bond0 -> ../../devices/virtual/net/bond0
-rw-r--r-- 1 root root 4096 Aug 7 12:56 bonding_masters
lrwxrwxrwx 1 root root 0 Aug 7 16:51 eno1 -> ../../devices/pci0000:00/0000:00:01.1/0000:04:00.0/net/eno1
lrwxrwxrwx 1 root root 0 Aug 7 16:51 eno2 -> ../../devices/pci0000:00/0000:00:01.1/0000:04:00.1/net/eno2
lrwxrwxrwx 1 root root 0 Aug 7 16:51 eno3 -> ../../devices/pci0000:80/0000:80:01.0/0000:81:00.0/net/eno3
lrwxrwxrwx 1 root root 0 Aug 7 16:51 eno4 -> ../../devices/pci0000:80/0000:80:01.0/0000:81:00.1/net/eno4
lrwxrwxrwx 1 root root 0 Aug 7 16:51 enp6s0 -> ../../devices/pci0000:00/0000:00:02.0/0000:06:00.0/net/enp6s0
lrwxrwxrwx 1 root root 0 Aug 7 16:51 enp6s0d1 -> ../../devices/pci0000:00/0000:00:02.0/0000:06:00.0/net/enp6s0d1
lrwxrwxrwx 1 root root 0 Aug 7 16:51 enp8s0 -> ../../devices/pci0000:00/0000:00:03.0/0000:08:00.0/net/enp8s0
lrwxrwxrwx 1 root root 0 Aug 7 16:51 enp8s0d1 -> ../../devices/pci0000:00/0000:00:03.0/0000:08:00.0/net/enp8s0d1
lrwxrwxrwx 1 root root 0 Aug 7 16:51 enp9s0 -> ../../devices/pci0000:00/0000:00:03.2/0000:09:00.0/net/enp9s0
lrwxrwxrwx 1 root root 0 Aug 7 16:51 enp9s0d1 -> ../../devices/pci0000:00/0000:00:03.2/0000:09:00.0/net/enp9s0d1
lrwxrwxrwx 1 root root 0 Aug 7 16:51 lo -> ../../devices/virtual/net/lo
root@xxx:~# lspci -nn |grep Ether
04:00.0 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
04:00.1 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
06:00.0 Ethernet controller [0200]: Mellanox Technologies MT27500 Family [ConnectX-3] [15b3:1003]
08:00.0 Ethernet controller [0200]: Mellanox Technologies MT27500 Family [ConnectX-3] [15b3:1003]
09:00.0 Ethernet controller [0200]: Mellanox Technologies MT27500 Family [ConnectX-3] [15b3:1003]
81:00.0 Ethernet controller [0200]: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 [8086:1528] (rev 01)
81:00.1 Ethernet controller [0200]: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 [8086:1528] (rev 01)