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 ...
随机推荐
- Hash的一点测试
哈希表的学习与测试 以前写的hash都是碰运气的hash,就是乘上质数取模的那种,这样不能保证不碰撞,所以今天先写上几个双hush和链表的hash,并比较一下他们的速度,测试的话用洛谷上的“字符串哈希 ...
- mysql sleep连接过多解决办法
睡眠连接过多,会对mysql服务器造成什么影响? 严重消耗mysql服务器资源(主要是cpu, 内存),并可能导致mysql崩溃. 造成睡眠连接过多的原因? 1. 使用了太多持久连接(个人觉得,在高并 ...
- ORM PetaPoco 框架的 CRUD 操作
PetaPoco 的查询操作 public IEnumerable<T> GetAll(string sqlString, object[] obj) { try { IEnumerabl ...
- faker之python构造虚拟数据
python中可以使用faker来制造一些虚拟数据 首选安装faker pip install Faker 老版的叫法是faker-factory,但是已不适用 使用faker.Factory.cre ...
- face,Pool
.a 在使用Python进行系统管理时,特别是同时操作多个文件目录或者远程控制多台主机,并行操作可以节约大量的时间.如果操作的对象数目不大时,还可以直接使用Process类动态的生成多个进程 ,十几个 ...
- msq_table's methods
-- 查看有哪些用户 host: % 代表任意地址都可以登录 host: localhost 代表仅本地可以连接select host,user from mysql.user; -- 建库 crea ...
- leetcode27
public class Solution { public int RemoveElement(int[] nums, int val) { var len = nums.Length; ; ; i ...
- 在 WampServer 上手工安装 PHP 的多个版本
手工安装新版本的PHP,只需以下步骤: 下载要安装的PHP版本.既然是用WampServer,那当然是下载Window版本的ZIP包啦:http://windows.php.net.解压到 Wamp的 ...
- 迷你MVVM框架 avalonjs 学习教程21、双向绑定链
avalon的双向绑定机制,是通过一条依赖链实现.此依赖链最底层是监控属性.监控数组,中层是计算属性.监控函数,再上点是求值函数,最上层是视图刷新函数. 所谓计算属性,监控属性,监控函数属性,我们改变 ...
- hadoop 官方配置文件解析
比如我的版本是2.8.4 官网文档是: http://hadoop.apache.org/docs/r2.8.4/ 基本配置文件:包括一般的端口 hdfs-default.xml dfs.nameno ...