Home > Backend Development > Python Tutorial > Python gets the manufacturer and model information of the server

Python gets the manufacturer and model information of the server

高洛峰
Release: 2016-10-18 09:39:53
Original
1456 people have browsed it

Python obtains the manufacturer and model information of the server. Under RHEHL6, the system needs to have the python-dmidecode package pre-installed (it seems to have been installed by default)

The content of the script is as follows

[root@linuxidc tmp]# cat test.py

#!/usr/bin/env python
import dmidecode
info=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']
Copy after login

[root@linuxidc tmp]#

When executed, root permission is required, the output is as follows:

[root@linuxidc tmp]# ./test.py

HP
ProLiant DL380p Gen8
Copy after login

First The first row is the manufacturer HP, and the second row is the model number of the HP server.

Note: The way to obtain this information through the dmidecode command is:

dmidecode -t1
Copy after login

The output is as follows:

[root@linuxidc tmp]# dmidecode -t1

# dmidecode 2.11
SMBIOS 2.7 present.
  
Handle 0x0100, DMI type 1, 27 bytes
System 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
Copy after login

[root@linuxidc tmp ]#


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template