通过pip install wmi安装wmi

查看cpu序列号:

wmic cpu get processorid



查看主板序列号:

wmic baseboard get serialnumber



查看网卡信息:

wmic nicconfig get macaddress



通过Python获取

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys
import wmi
c = wmi.WMI() # 处理器
def printCPU():
tmpdict = {}
tmpdict["CpuCores"] = 0
for cpu in c.Win32_Processor():
tmpdict["cpuid"] = cpu.ProcessorId.strip()
tmpdict["CpuType"] = cpu.Name
tmpdict['systemName'] = cpu.SystemName
try:
tmpdict["CpuCores"] = cpu.NumberOfCores
except:
tmpdict["CpuCores"] += 1
tmpdict["CpuClock"] = cpu.MaxClockSpeed
tmpdict['DataWidth'] = cpu.DataWidth
print (tmpdict)
return tmpdict # 主板
def printMain_board():
boards = []
# print len(c.Win32_BaseBoard()):
for board_id in c.Win32_BaseBoard():
tmpmsg = {}
tmpmsg['UUID'] = board_id.qualifiers['UUID'][1:-1] # 主板UUID,有的主板这部分信息取到为空值,ffffff-ffffff这样的
tmpmsg['SerialNumber'] = board_id.SerialNumber # 主板序列号
tmpmsg['Manufacturer'] = board_id.Manufacturer # 主板生产品牌厂家
tmpmsg['Product'] = board_id.Product # 主板型号
boards.append(tmpmsg)
print (boards)
return boards # BIOS
def printBIOS():
bioss = []
for bios_id in c.Win32_BIOS():
tmpmsg = {}
tmpmsg['BiosCharacteristics'] = bios_id.BiosCharacteristics # BIOS特征码
tmpmsg['version'] = bios_id.Version # BIOS版本
tmpmsg['Manufacturer'] = bios_id.Manufacturer.strip() # BIOS固件生产厂家
tmpmsg['ReleaseDate'] = bios_id.ReleaseDate # BIOS释放日期
tmpmsg['SMBIOSBIOSVersion'] = bios_id.SMBIOSBIOSVersion # 系统管理规范版本
bioss.append(tmpmsg)
print (bioss)
return bioss # 硬盘
def printDisk():
disks = []
for disk in c.Win32_DiskDrive():
# print disk.__dict__
tmpmsg = {}
tmpmsg['SerialNumber'] = disk.SerialNumber.strip()
tmpmsg['DeviceID'] = disk.DeviceID
tmpmsg['Caption'] = disk.Caption
tmpmsg['Size'] = disk.Size
tmpmsg['UUID'] = disk.qualifiers['UUID'][1:-1]
disks.append(tmpmsg)
for d in disks:
print (d)
return disks # 内存
def printPhysicalMemory():
memorys = []
for mem in c.Win32_PhysicalMemory():
tmpmsg = {}
tmpmsg['UUID'] = mem.qualifiers['UUID'][1:-1]
tmpmsg['BankLabel'] = mem.BankLabel
tmpmsg['SerialNumber'] = mem.SerialNumber.strip()
# tmpmsg['ConfiguredClockSpeed'] = mem.ConfiguredClockSpeed
tmpmsg['Capacity'] = mem.Capacity
# tmpmsg['ConfiguredVoltage'] = mem.ConfiguredVoltage
memorys.append(tmpmsg)
for m in memorys:
print (m)
return memorys # 电池信息,只有笔记本才会有电池选项
def printBattery():
isBatterys = False
for b in c.Win32_Battery():
isBatterys = True
return isBatterys # 网卡mac地址:
def printMacAddress():
macs = []
for n in c.Win32_NetworkAdapter():
mactmp = n.MACAddress
if mactmp and len(mactmp.strip()) > 5:
tmpmsg = {}
tmpmsg['MACAddress'] = n.MACAddress
tmpmsg['Name'] = n.Name
tmpmsg['DeviceID'] = n.DeviceID
tmpmsg['AdapterType'] = n.AdapterType
tmpmsg['Speed'] = n.Speed
macs.append(tmpmsg)
print (macs)
return macs def main(): printCPU()
printMain_board()
printBIOS()
printDisk()
printPhysicalMemory()
printMacAddress()
printBattery() if __name__ == '__main__':
main()

Python 通过wmi获取Window服务器硬件信息的更多相关文章

  1. Python使用wmi获取Windows相关信息

    在使用Python获取Windows系统上的相关的信息可以使用WMI接口来获取, 什么是wmi? WMI是一项核心的Windows管理技术,WMI作为一种规范和基础结构,通过它可以访问.配置.管理和监 ...

  2. Python 通过dmidecode获取Linux服务器硬件信息

    通过 dmidecode 命令可以获取到 Linux 系统的包括 BIOS. CPU.内存等系统的硬件信息,这里使用 python 代码来通过调用 dmidecode 命令来获取 Linux 必要的系 ...

  3. 通过wmi获取本地硬件信息的一些疑问。

    通过wmi获取本地硬件信息的一些疑问. http://bbs.csdn.net/topics/391017789 http://blog.csdn.net/xcntime/article/detail ...

  4. 用PYTHON + PYWIN32 + WMI获取WINDOWS系统基本信息

    网上原码,去了DECODE编码的问题. PyScripter这个PYTHON的IDE工具在WIN下表现不错哟. 感觉比SPYDER,ERIC,SUBLEME TEXT3之类的好用呀.. #!/usr/ ...

  5. 利用python 与 wmi 获取WINDOWS基本信息

    #!/usr/bin/env python3.5 # -*- coding:utf8 -*- import platform import subprocess import wmi def serv ...

  6. Python基础:获取平台相关信息

    Windows 10家庭中文版,Python 3.6.4, 本文介绍了使用os.platform.sys三个模块获取Python程序的运行平台相关的信息. os模块:提供 各种各样的操作系统接口 os ...

  7. C++ WMI获取系统硬件信息(CPU/DISK/NetWork etc)

    官网找到一个例子,根据例子修改下可以获取很多信息 #define _WIN32_DCOM #include <iostream> using namespace std; #include ...

  8. python开发_platform_获取操作系统详细信息工具

    ''' python中,platform模块给我们提供了很多方法去获取操作系统的信息 如: import platform platform.platform() #获取操作系统名称及版本号,'Win ...

  9. c# WMI获取机器硬件信息(硬盘,cpu,内存等)

    using System; using System.Collections.Generic; using System.Globalization; using System.Management; ...

随机推荐

  1. vue 使用 axios 时 post 请求方法传参无法发送至后台

    axios 时 post 请求方法传参无法发送至后台报错如下 Response to preflight request doesn't pass access control check: No ' ...

  2. (67)c++后台开发

    还记得自己在学校的时候,一直都比较注重的是:编程语言+数据结构与算法.没错,对于一个在校的计算机专业的学生,这是很重要的方面.但是,这往往不够,或许是因为毕业前一直没有进入企业实习,以至于自己在毕业之 ...

  3. bootstraptable表格columns 隐藏方法

    隐藏:  visible: false,   显示:visible: true, visible属性没有true或者false,是visible,invisible和gone.visible:可见的: ...

  4. 大v用户数据统计分析

    1,统计数据的基本情况,包括微博总数,用户总数,最活跃和最不活跃的用户id #!/bin/sh source_dir=/home/minelab/data/DATA source_file_name= ...

  5. 错误1919,配置ODBC数据源MS Access Database时发生错误ODEC错误

    WIN7 64位旗舰版安装OFFICE2003 提示:“错误1919,配置ODBC数据源MS Access Database时发生错误ODEC错误” 在64位系统上,32位软件的注册表的信息不是直接在 ...

  6. legend3---Homestead中Laravel项目502 Bad Gateway

    legend3---Homestead中Laravel项目502 Bad Gateway 一.总结 一句话总结: 用查看错误日志的方法解决错误:(/var/log/nginx/.log) 1.home ...

  7. day66—angularJS学习笔记-表达式

    转行学开发,代码100天——2018-05-21 angular的变量数据初始化: ng-init="quantity=1;cost=30;student={firstName:'李',la ...

  8. 基于注解的springmvc开发

    原理简析 1. 背景知识:org.springframework.web.ServletContainerInitializer接口 在基于注解的servlet开发中,ServletContainer ...

  9. python学习笔记:(六)str(字符串)常用方法

    注意点: 1.字符串是不可变的: 2.%格式化操作符:左侧放置字符串,右侧放置希望被格式化的值. 对于单个字符的编码,Python提供了ord()函数获取字符的整数表示,chr()函数把编码转换为对应 ...

  10. Jmeter接口测试系列之测试用例变量参数化处理

    在进行接口测试时,一组完整的接口测试用例,存在后一个测试用例使用前一个用例的请求结果中的数据,此时就需要参数化测试用例中值.直接使用变量调用会存在问题,此时就需要用到beanshell去改变. 举例说 ...