Python用WMI模块获取Windows系统的硬件信息:硬盘分区、使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息。

本文实例讲述了python使用wmi模块获取windows下的系统信息 监控系统

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python 
# -*- coding: utf- -*- 
#http://www.cnblogs.com/liu-ke/
import wmi 
import os 
import sys 
import platform 
import time 
def sys_version(): 
  = wmi.WMI () 
  #获取操作系统版本 
  for sys in c.Win_OperatingSystem(): 
    print "Version:%s" % sys.Caption.encode("UTF"),"Vernum:%s" % sys.BuildNumber 
    print sys.OSArchitecture.encode("UTF")#系统是位还是位的 
    print sys.NumberOfProcesses #当前系统运行的进程总数
def cpu_mem(): 
  = wmi.WMI ()    
  #CPU类型和内存 
  for processor in c.Win_Processor(): 
    #print "Processor ID: %s" % processor.DeviceID 
    print "Process Name: %s" % processor.Name.strip() 
  for Memory in c.Win_PhysicalMemory(): 
    print "Memory Capacity: %.fMB" %(int(Memory.Capacity)/
def disk(): 
  = wmi.WMI ()  
  #获取硬盘分区 
  for physical_disk in c.Win_DiskDrive (): 
    for partition in physical_disk.associators ("Win_DiskDriveToDiskPartition"): 
      for logical_disk in partition.associators ("Win_LogicalDiskToPartition"): 
        print physical_disk.Caption.encode("UTF"), partition.Caption.encode("UTF"), logical_disk.Caption 
  #获取硬盘使用百分情况 
  for disk in c.Win_LogicalDisk (DriveType=): 
    print disk.Caption, "%.f%% free" % (. * long (disk.FreeSpace) / long (disk.Size)) 
def network(): 
  = wmi.WMI ()  
  #获取MAC和IP地址 
  for interface in c.Win_NetworkAdapterConfiguration (IPEnabled=): 
    print "MAC: %s" % interface.MACAddress 
  for ip_address in interface.IPAddress: 
    print "ip_add: %s" % ip_address 
  print
def main(): 
  sys_version() 
  cpu_mem() 
  #disk() 
  #network() 
if __name__ == '__main__'
  main() 
  print platform.system() 
  print platform.release() 
  print platform.version() 
  print platform.platform() 
  print platform.machine()

以上内容是关于python使用wmi模块获取windows下的系统信息 监控系统的相关知识,希望对大家有所帮助。

www.qytang.com/
http://www.qytang.com/cn/list/29/
http://www.qytang.com/cn/list/28/446.htm
http://www.qytang.com/cn/list/28/445.htm
http://www.qytang.com/cn/list/28/444.htm
http://www.qytang.com/cn/list/28/442.htm
http://www.qytang.com/cn/list/28/440.htm
http://www.qytang.com/cn/list/28/437.htm
http://www.qytang.com/cn/list/28/435.htm
http://www.qytang.com/cn/list/28/434.htm
http://www.qytang.com/cn/list/28/433.htm
http://www.qytang.com/cn/list/28/431.htm
http://www.qytang.com/cn/list/28/328.htm
http://www.qytang.com/cn/list/28/326.htm
http://www.qytang.com/cn/list/28/429.htm

python使用wmi模块获取windows下的系统信息监控系统-乾颐堂的更多相关文章

  1. Python使用WMI模块获取Windows系统的硬件信息,并使用pyinstaller库编译打包成exe的可执行文件

    由于公司现阶段大多数应用软件都是基于Windows系统开发和部署,很多软件安装部署都是在windows server 2012.windows server 2008之类的服务器上,部门同事每次测试一 ...

  2. python wmi模块 获取windows内部信息

    WMI (Windows Management Instrumentation) 模块可用于获取 Windows 内部信息,在使用Python获取Windows系统上的相关的信息可以使用WMI接口来获 ...

  3. python中os模块在windows下的使用

    今天学习了一下Python的os模块,主要是针对文件夹和文件路径的一系列操作. 与Python内置函数相比这里这里的函数功能更多样化,功能也更强大.但是学习过程中我发现很多函数都是只适用于unix系统 ...

  4. Python用WMI模块获取windowns系统信息

    安装vmi https://pypi.org/project/WMI/#history 脚本如下: #!/usr/bin/env python #coding:utf- import wmi impo ...

  5. python用WMI模块获取系统命名空间

    可以和winmgmts的查询页面对应 from win32com.client import GetObject import pywintypes result=[] def enum_namesp ...

  6. Python获取服务器的厂商和型号信息-乾颐堂

    Python获取服务器的厂商和型号信息,在RHEHL6下,需要系统预装python-dmidecode这个包(貌似默认就已经装过了) 脚本内容如下 [root@linuxidc tmp]# cat t ...

  7. HTTP 499状态码 nginx下499错误详解-乾颐堂

    日志记录中HTTP状态码出现499错误有多种情况,我遇到的一种情况是nginx反代到一个永远打不开的后端,就这样了,日志状态记录是499.发送字节数是0. 老是有用户反映网站系统时好时坏,因为线上的产 ...

  8. Python的requests、greenlet和gevent模块在windows下安装

    一.requests模块在windows下安装 Linux系统下requests的安装方法在http://docs.python-requests.org/en/latest/user/install ...

  9. python封装configparser模块获取conf.ini值(优化版)

    昨天晚上封装了configparser模块,是根据keyname获取的value.python封装configparser模块获取conf.ini值 我原本是想通过config.ini文件中的sect ...

随机推荐

  1. node使用MySQL数据库

    内容: 1.node连接数据库 2.数据库常用操作 3.数据库实例 - 用户注册.登陆 1.node连接数据库 (1)下载mysql模块 (2)使用mysql模块连接数据库 let db=mysql. ...

  2. jQuery ajax - serializeArray() 方法

    定义和用法 serializeArray() 方法通过序列化表单值来创建对象数组(名称和值). 您可以选择一个或多个表单元素(比如 input 及/或 textarea),或者 form 元素本身. ...

  3. linux系统更新rpm包问题 ,报错rhn-check-2.0.2-5.el7.noarch has missing requires of yum-rhn-plugin >= ('0', '1.6.4', '1')

    报错信息: rhn-check-2.0.2-5.el7.noarch has missing requires of yum-rhn-plugin >= ('0', '1.6.4', '1') ...

  4. hive xml udf

    <store>   <book id="book"><title id="titile">hive</title> ...

  5. XE 创建 Active Form

    XE6: http://docwiki.embarcadero.com/RADStudio/XE6/en/Generating_an_Active_Form_Based_on_a_VCL_Form h ...

  6. objective C, parse json时注意事项

    例: dict为从API请求返回的json调用 NSJSONSerialization JSONObjectWithData:方法得到的NSDictionary实例. 当执行以下语句时linkStri ...

  7. mouseenter 事件

    定义和用法 当鼠标指针穿过元素时,会发生 mouseenter 事件. 该事件大多数时候会与 mouseleave 事件一起使用. mouseenter() 方法触发 mouseenter 事件,或规 ...

  8. 自动选择最佳特征进行分类-SVM (Halcon)

    HALCON12里的example,classify_pills_auto_select_features.hdev. 执行流程: 1.选取相关特征(本例选取color和region组的所有特征)(本 ...

  9. spring cloud DashBoard

    1 依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring ...

  10. 在JSP页面中显示动态时间

    源地址:http://blog.csdn.net/aitcax/article/details/41285305 静态时间: 1.页面首部添加 <%@page import="java ...