批量查看服务器的FC HBA卡wwn地址和端口状态

方法一:

[root@langchao048 ~]# for i in 0 1 2 3 4 5; do cat /sys/class/fc_host/host$i/port_name; done
cat: /sys/class/fc_host/host0/port_name: No such file or directory
0x10000090fae416b3
0x10000090fae416b7
0x10000090fadf84c5
0x10000090fadf84c9
cat: /sys/class/fc_host/host5/port_name: No such file or directory

方法二:

[root@langchao048 ~]# ls -1c /sys/class/fc_host/host*/*_name 2> /dev/null | xargs -I {} grep -H -v “ZzZz” {} | sort
/sys/class/fc_host/host1/fabric_name:0x2002002a6a1dc4c1
/sys/class/fc_host/host1/node_name:0x20000090fae416b3
/sys/class/fc_host/host1/port_name:0x10000090fae416b3
/sys/class/fc_host/host1/symbolic_name:Emulex OCe11102-FM FV10.6.144.21 DV11.0.0.4 HN:(none) OS:Linux
/sys/class/fc_host/host2/fabric_name:0x0
/sys/class/fc_host/host2/node_name:0x20000090fae416b7
/sys/class/fc_host/host2/port_name:0x10000090fae416b7
/sys/class/fc_host/host2/symbolic_name:Emulex OCe11102-FM FV10.6.144.21 DV11.0.0.4 HN:(none) OS:Linux
/sys/class/fc_host/host3/fabric_name:0x2002002a6a15a841
/sys/class/fc_host/host3/node_name:0x20000090fadf84c5
/sys/class/fc_host/host3/port_name:0x10000090fadf84c5
/sys/class/fc_host/host3/symbolic_name:Emulex OCe11102-FM FV10.6.144.21 DV11.0.0.4 HN:(none) OS:Linux
/sys/class/fc_host/host4/fabric_name:0x0
/sys/class/fc_host/host4/node_name:0x20000090fadf84c9
/sys/class/fc_host/host4/port_name:0x10000090fadf84c9
/sys/class/fc_host/host4/symbolic_name:Emulex OCe11102-FM FV10.6.144.21 DV11.0.0.4 HN:(none) OS:Linux

 

方法三:先安装yum install sysfsutils
[root@langchao048 ~]# systool -c fc_host -v
Class = “fc_host”

Class Device = “host1”
Class Device path = “/sys/devices/pci0000:00/0000:00:03.0/0000:06:00.2/host1/fc_host/host1”
active_fc4s = “0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ”
dev_loss_tmo = “30”
fabric_name = “0x2002002a6a1dc4c1”
issue_lip = <store method only>
max_npiv_vports = “255”
maxframe_size = “2048 bytes”
node_name = “0x20000090fae416b3”
npiv_vports_inuse = “0”
port_id = “0x5b09a7”
port_name = “0x10000090fae416b3”
port_state = “Online”
port_type = “NPort (fabric via point-to-point)”
speed = “10 Gbit”
supported_classes = “Class 3”
supported_fc4s = “0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ”
supported_speeds = “10 Gbit”
symbolic_name = “Emulex OCe11102-FM FV10.6.144.21 DV11.0.0.4 HN:(none) OS:Linux”
tgtid_bind_type = “wwpn (World Wide Port Name)”
uevent =
vport_create = <store method only>
vport_delete = <store method only>

Device = “host1”
Device path = “/sys/devices/pci0000:00/0000:00:03.0/0000:06:00.2/host1”
uevent = “DEVTYPE=scsi_host”

Class Device = “host2”
Class Device path = “/sys/devices/pci0000:00/0000:00:03.0/0000:06:00.3/host2/fc_host/host2”
active_fc4s = “0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ”
dev_loss_tmo = “30”
fabric_name = “0x0”
issue_lip = <store method only>
max_npiv_vports = “255”
maxframe_size = “2048 bytes”
node_name = “0x20000090fae416b7”
npiv_vports_inuse = “0”
port_id = “0x000000”
port_name = “0x10000090fae416b7”
port_state = “Linkdown”
port_type = “Unknown”
speed = “unknown”
supported_classes = “Class 3”
supported_fc4s = “0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ”
supported_speeds = “10 Gbit”
symbolic_name = “Emulex OCe11102-FM FV10.6.144.21 DV11.0.0.4 HN:(none) OS:Linux”
tgtid_bind_type = “wwpn (World Wide Port Name)”
uevent =
vport_create = <store method only>
vport_delete = <store method only>

Device = “host2”
Device path = “/sys/devices/pci0000:00/0000:00:03.0/0000:06:00.3/host2”
uevent = “DEVTYPE=scsi_host”

Class Device = “host3”
Class Device path = “/sys/devices/pci0000:40/0000:40:02.0/0000:42:00.2/host3/fc_host/host3”
active_fc4s = “0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ”
dev_loss_tmo = “30”
fabric_name = “0x2002002a6a15a841”
issue_lip = <store method only>
max_npiv_vports = “255”
maxframe_size = “2048 bytes”
node_name = “0x20000090fadf84c5”
npiv_vports_inuse = “0”
port_id = “0x8505c7”
port_name = “0x10000090fadf84c5”
port_state = “Online”
port_type = “NPort (fabric via point-to-point)”
speed = “10 Gbit”
supported_classes = “Class 3”
supported_fc4s = “0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ”
supported_speeds = “10 Gbit”
symbolic_name = “Emulex OCe11102-FM FV10.6.144.21 DV11.0.0.4 HN:(none) OS:Linux”
tgtid_bind_type = “wwpn (World Wide Port Name)”
uevent =
vport_create = <store method only>
vport_delete = <store method only>

Device = “host3”
Device path = “/sys/devices/pci0000:40/0000:40:02.0/0000:42:00.2/host3”
uevent = “DEVTYPE=scsi_host”

Class Device = “host4”
Class Device path = “/sys/devices/pci0000:40/0000:40:02.0/0000:42:00.3/host4/fc_host/host4”
active_fc4s = “0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ”
dev_loss_tmo = “30”
fabric_name = “0x0”
issue_lip = <store method only>
max_npiv_vports = “255”
maxframe_size = “2048 bytes”
node_name = “0x20000090fadf84c9”
npiv_vports_inuse = “0”
port_id = “0x000000”
port_name = “0x10000090fadf84c9”
port_state = “Linkdown”
port_type = “Unknown”
speed = “unknown”
supported_classes = “Class 3”
supported_fc4s = “0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ”
supported_speeds = “10 Gbit”
symbolic_name = “Emulex OCe11102-FM FV10.6.144.21 DV11.0.0.4 HN:(none) OS:Linux”
tgtid_bind_type = “wwpn (World Wide Port Name)”
uevent =
vport_create = <store method only>
vport_delete = <store method only>

Device = “host4”
Device path = “/sys/devices/pci0000:40/0000:40:02.0/0000:42:00.3/host4”
uevent = “DEVTYPE=scsi_host”