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. 初试mysql5.7.2新特性:多源复制(MySQL 5.7 multi-source replication)

    多源复制和多主复制的区别: 多主复制示意图: 多源复制示意图: 在my.cnf中添加crash safe特性参数:master_info_repository=TABLE;relay_log_info ...

  2. centos启用root账号登陆telnet

    1,shutdown iptables或是放行23端口 2,shutdown selinux或是设置放行; 3,yum -y install telnet telnet-server 4,vim /e ...

  3. 使用phpExcelReader操作excel提示The filename *.xls is not readable的详细解决方法

    使用phpExcelReader操作excel提示The filename *.xls is not readable的详细解决方法 是xls文件有问题,另存为新的xls文件,然后导入就不会有这个问题

  4. PHP过滤各种HTML标签的表达式,值得收藏

    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 3 ...

  5. Win10交换Ctrl和大写键

    打开注册表 [HKEY_LOCAL_MacHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map" ...

  6. Sqoop增量导入

    Argument Description --check-column (col) Specifies the column to be examined when determining which ...

  7. greenlet 实现手动协程切换

    from greenlet import greenlet def test1(): print('12') gr2.switch() #切换到gr2 print('34') gr2.switch() ...

  8. 迷你MVVM框架 avalonjs 1.4发布

    主要带来以下三大改进: 全新的兼容AMD规范requirejs API的加载器 使用gulp进行构建 兼容性更好的触屏模块 最近还修改了avalon.modern bind方法的BUG,自定义过滤器的 ...

  9. Linux就业技术指导(五):Linux运维核心管理命令详解

    一,Linux核心进程管理命令 1.1 ps:查看进程 1.1.1 命令解释 功能说明 ps命令用于列出执行ps命令的那个时刻的进程快照,就像用手机给进程照了一张照片.如果想要动态地显示进程,就需要使 ...

  10. gff/gtf格式

    1)gff3及gtf2简介 一个物种的基因组测序完成后,需要对这些数据进行解读,首先要先找到这些序列中转录起始位点.基因.外显子.内含子等组成元件在染色体中的位置信息(即注释)后才能再进行深入的分析. ...