python使用wmi模块获取windows下的系统信息监控系统-乾颐堂
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(): c = 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(): c = 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(): c = 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(): c = 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 printdef 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下的系统信息监控系统-乾颐堂的更多相关文章
- Python使用WMI模块获取Windows系统的硬件信息,并使用pyinstaller库编译打包成exe的可执行文件
由于公司现阶段大多数应用软件都是基于Windows系统开发和部署,很多软件安装部署都是在windows server 2012.windows server 2008之类的服务器上,部门同事每次测试一 ...
- python wmi模块 获取windows内部信息
WMI (Windows Management Instrumentation) 模块可用于获取 Windows 内部信息,在使用Python获取Windows系统上的相关的信息可以使用WMI接口来获 ...
- python中os模块在windows下的使用
今天学习了一下Python的os模块,主要是针对文件夹和文件路径的一系列操作. 与Python内置函数相比这里这里的函数功能更多样化,功能也更强大.但是学习过程中我发现很多函数都是只适用于unix系统 ...
- Python用WMI模块获取windowns系统信息
安装vmi https://pypi.org/project/WMI/#history 脚本如下: #!/usr/bin/env python #coding:utf- import wmi impo ...
- python用WMI模块获取系统命名空间
可以和winmgmts的查询页面对应 from win32com.client import GetObject import pywintypes result=[] def enum_namesp ...
- Python获取服务器的厂商和型号信息-乾颐堂
Python获取服务器的厂商和型号信息,在RHEHL6下,需要系统预装python-dmidecode这个包(貌似默认就已经装过了) 脚本内容如下 [root@linuxidc tmp]# cat t ...
- HTTP 499状态码 nginx下499错误详解-乾颐堂
日志记录中HTTP状态码出现499错误有多种情况,我遇到的一种情况是nginx反代到一个永远打不开的后端,就这样了,日志状态记录是499.发送字节数是0. 老是有用户反映网站系统时好时坏,因为线上的产 ...
- Python的requests、greenlet和gevent模块在windows下安装
一.requests模块在windows下安装 Linux系统下requests的安装方法在http://docs.python-requests.org/en/latest/user/install ...
- python封装configparser模块获取conf.ini值(优化版)
昨天晚上封装了configparser模块,是根据keyname获取的value.python封装configparser模块获取conf.ini值 我原本是想通过config.ini文件中的sect ...
随机推荐
- 代码: js日期
日期格式化 (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2015-11-16 08:09:04.423 (new Dat ...
- HTML5 移动端 自定义点击事件
/* 封装的TAP事件 */ (function () { /** * IOS 和 PC 端 只需要创建一次就能一直使用 * Android 手机 每次使用的时候都需要从新创建 */ function ...
- RabbitMQ 端口号解析
转自:https://www.cnblogs.com/liuxingke/articles/9889517.html 端口号解析 12345 - 4369 (epmd), 25672 (Erlang ...
- Virus
c:\windows\syswow64\rundll32.exe C:\Users\Administrator.mt1-PC\AppData\Roaming\FishSearch
- jquery checkbox
$(document).ready(function() { var $cr = $("#cr"); var cr = $cr[0]; $cr.click(function() { ...
- where 命令
在当前目录及path环境变量指定的目录中搜索相应文件 例:where msbuild 查找msbuild的位置
- python classmethod 和 staticmethod的区别
https://stackoverflow.com/questions/12179271/meaning-of-classmethod-and-staticmethod-for-beginner 1. ...
- JDK和Tomcat部署时,版本不同的问题解决
问题: 在以Tomcat作为Web容器,启动java Web工程时,遇到下面问题:org.eclipse.jdt.internal.compiler.classfmt.ClassFormatExcep ...
- docker 配置远程访问证书验证
centos7 生成证书 工具:openssl #cd /etc/docker (docker的证书一般放这) #openssl genrsa -aes256 -passout pass:密码 ...
- Ansible 从MySQL数据库添加或删除用户
mysql_user - 从MySQL数据库添加或删除用户. 概要 要求(在执行模块的主机上) 选项 例子 笔记 状态 支持 概要 从MySQL数据库添加或删除用户. 要求(在执行模块的主机上) My ...