The serial number (SN) that the vendor burns into the motherboard is unique and can be used as a unique index for a single server. The serial number of the server can be easily crawled by the Dmidecode command under Linux.
However, because of the various manufacturers of SMBIOS brush write specifications are not the same, we need to do some compatible operation.
A brief summary, see the table below
Manufacturers |
General Crawl Method |
Dell |
Dmidecode-s System-serial-number
|
Hp |
Dmidecode-s System-serial-number
|
Ibm |
Dmidecode-s System-serial-number
|
Huawei |
Dmidecode-s System-serial-number (Huawei Rack Server) or Dmidecode-s Baseboard-serial-number (Huawei Blades)
|
Use a shell to cover all models, as follows:
GET_SN () { local mysn= ' dmidecode -s system-serial-number | grep -v ' # ' if echo "${MYSN}" | grep -qiE "^notspecified|^none|^tobefilledbyo.e.m.| O.E.M. " ; then mysn= ' Dmidecode -s baseboard-serial-number ' fi #对于RHEL4和CentOS4, Dmidecode does not support the-s parameter, Different SN acquisition methods are required if grep -q ' release 4 ' /etc/redhat-release ; then mysn= ' dmidecode | grep -a5 ' system information ' | grep ' Serial number ' | awk ' {PRINT&NBsp;$3} ' | sed ' s/^[ \t]*//g ' | sed ' s/[ \t]$//g ' fi echo $mySN }
Want to help with server operations.
The original url:http://www.opstool.com/article/195 OPS Maintenance tool is worth reference!!!
Capturing the motherboard's serial number (SN) using Dmidecode