Python gets the server's manufacturer and model information, under RHEHL6, requires the system preinstalled Python-dmidecode this package (it seems to have been installed by default)
The script content is as follows
[ROOT@LINUXIDC tmp]# Cat test.py
#!/usr/bin/env pythonimport Dmidecodeinfo=dmidecode.system () Info_keys=info.keys () for I in Range (len (Info_keys)): if info[info_keys[i]][' dmi_type ' = = 1: print info[info_keys[i]][' data ' [' manufacturer '] print info[ info_keys[i]][' data ' [' Product Name ']
[ROOT@LINUXIDC tmp]#
When executing, the root permission is required and the output is as follows:
[ROOT@LINUXIDC tmp]#./test.py
Hpproliant dl380p Gen8
The first line is manufacturer HP, and the second line is the model of the HP server.
Note: This information is obtained through the Dmidecode command in the following ways:
Dmidecode-t1
The output is as follows:
[ROOT@LINUXIDC tmp]# Dmidecode-t1
# Dmidecode 2.11SMBIOS 2.7 present. Handle 0x0100, DMI type 1, bytessystem information manufacturer:hp Product name:proliant dl380p Gen8 Vers Ion:not Specified Serial number:cng230shdq uuid:32333536-3030-4e43-4732-333053484451 wake-up Type: Power Switch SKU number:653200-b21 family:proliant
[ROOT@LINUXIDC tmp]#