File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6969
7070# Associative array /dev/nvme names keyed by serial number
7171declare -A deviceName
72+ declare -A devicePCIAddress
7273
7374# execute <fn<path>> <args...>
7475execute () {
@@ -178,6 +179,17 @@ setDeviceName() {
178179 do
179180 SerialNumber=$( nvme id-ctrl " ${DRIVE} " | grep -E " ^sn " | awk ' {print $3}' )
180181 deviceName[$SerialNumber ]=$DRIVE
182+
183+ # Get the PCI address of the NVMe device
184+ local dev
185+ dev=$( basename " $DRIVE " )
186+ local devpath=/sys/class/nvme/$dev
187+ local pcie_path
188+ pcie_path=$( readlink -f " $devpath " )
189+ local pci
190+ pci=$( echo " $pcie_path " | grep -oP ' [0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9]' | tail -n1)
191+
192+ devicePCIAddress[$SerialNumber ]=" $pci "
181193 done
182194}
183195
@@ -252,17 +264,19 @@ displayDriveSlotStatus() {
252264 FW=" $( printf ' %s\n' " ${idCtrl[@]} " | grep -E " ^fr " | awk ' {print $3}' ) "
253265 SN=" $( printf ' %s\n' " ${idCtrl[@]} " | grep -E " ^sn " | awk ' {print $3}' ) "
254266 Device=" ${deviceName["$SN"]} "
267+ DeviceAddress=" ${devicePCIAddress["$SN"]} "
255268 ;;
256269 * )
257270 MF=" Unavail"
258271 SN=" Unavail"
259272 FW=" Unavail"
260273 Device=" Unavail"
274+ DeviceAddress=" Unavail"
261275 ;;
262276 esac
263277 fi
264278
265- printf " PDFID: %6.6s\tSLOT: %2.2d %15.15s %s %s %15.15s %s\n" " ${PDFID// } " " ${SLOT// } " " $MF " " $SN " " $FW " " $Device " " ${physicalPortString// } "
279+ printf " PDFID: %6.6s\tSLOT: %2.2d %15.15s %s %s %15.15s %13.13s % s\n" " ${PDFID// } " " ${SLOT// } " " $MF " " $SN " " $FW " " $Device " " $DeviceAddress " " ${physicalPortString// } "
266280 fi
267281 done
268282 printf " \n"
You can’t perform that action at this time.
0 commit comments