zoukankan      html  css  js  c++  java
  • Python获取服务器的厂商和型号信息-乾颐堂

    Python获取服务器的厂商和型号信息,在RHEHL6下,需要系统预装python-dmidecode这个包(貌似默认就已经装过了)

    脚本内容如下

    [root@linuxidc tmp]# cat test.py

    1
    2
    3
    4
    5
    6
    7
    8
    #!/usr/bin/env python
    import dmidecode
    info=dmidecode.system()
    info_keys=info.keys()
    for 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]#

    执行的时候,需要root权限,输出如下:

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

    1
    2
    HP
    ProLiant DL380p Gen8

    第一行是厂商HP,第二行是HP服务器的型号。

    注:通过dmidecode命令获取这些信息的方式是:

    1
    dmidecode -t1

    输出如下:

    [root@linuxidc tmp]# dmidecode -t1

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    # 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

    [root@linuxidc tmp]#

    http://www.qytang.com/
    http://www.qytang.com/cn/list/29/
    http://www.qytang.com/cn/list/28/428.htm
    http://www.qytang.com/cn/list/28/426.htm
    http://www.qytang.com/cn/list/28/425.htm
    http://www.qytang.com/cn/list/28/424.htm
    http://www.qytang.com/cn/list/28/423.htm
    http://www.qytang.com/cn/list/28/422.htm
    http://www.qytang.com/cn/list/28/421.htm
    http://www.qytang.com/cn/list/28/420.htm
    http://www.qytang.com/cn/list/28/417.htm
    http://www.qytang.com/cn/list/28/416.htm
    http://www.qytang.com/cn/list/28/407.htm
    http://www.qytang.com/cn/list/28/403.htm

  • 相关阅读:
    *****.NET程序首次加載慢問題
    *****How to access a repositoryItemButtonEdit value from a FileDlg
    抽象类与接口的区别
    C#中使用Split分隔字符串的技巧
    *****User Control Instance/DataGridView.Columns in Visual Studio Design
    LinksPersistInfo not work!
    LookUpEdit用法
    Devpress.XtraGrid.GridControl 笔记
    *****动态执行sql
    *****LookUpEdit hide columns
  • 原文地址:https://www.cnblogs.com/qytang/p/5570554.html
Copyright © 2011-2022 走看看