RHCA战友群里面柱子哥给的脚本,用来搜集主机上的内存和插槽对应的情况

dmidecode -t 17 | awk '/Size:.*MB/{size=$0/^[[:space:]]+Locator/{if(size){print size,$0;size=0}}'        Size: 2048 MB   Locator: DIMM03        Size: 2048 MB   Locator: DIMM06        Size: 2048 MB   Locator: DIMM08        Size: 2048 MB   Locator: DIMM11        Size: 2048 MB   Locator: DIMM14        Size: 2048 MB   Locator: DIMM16

我私自修改了一下,去掉了前导空格,插槽位置的检索页

dmidecode -t 17 | awk '/Size:.*MB/{size=$1" "$2" "$3}/Locator/{if(size){print size,$0;size=0}}'Size: 4096 MB   Locator: DIMM00Size: 4096 MB   Locator: DIMM00