Python obtains server vendor and model information. Python obtains server vendor and model information. in RHEHL6, the python-dmidecode package needs to be pre-installed by the system (it seems that it has 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] #
During execution, the root permission is required and the output is as follows:
[Root @ linuxidc tmp] #./test. py
HPProLiant DL380p Gen8
The first line is the vendor HP, and the second line is the model of the HP server.
Note: The dmidecode command is used to obtain the information:
dmidecode -t1
The output is as follows:
[Root @ linuxidc tmp] # dmidecode-t1
# dmidecode 2.11SMBIOS 2.7 present. Handle 0x0100, DMI type 1, 27 bytesSystem Information Manufacturer: HP Product Name: ProLiant DL380p Gen8 Version: 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] #