python使用WMI监视系统-CPU使用率

import wmi
import time

c=wmi.WMI()
while True:
    for cpu inc.Win32_Processor():
         timestamp=time.strftime('%a, %d %b %Y %H:%M:%S',time.localtime())
        print '%s | Utilization: %s: %d %%' % (timestamp,cpu.DeviceID,cpu.LoadPercentage)
         time.sleep(5)

 

 

当然你需要wmi

wmi url:http://timgolden.me.uk/python/wmi/index.html

posted @ 2011-07-20 16:42  rorshach  阅读(881)  评论(0编辑  收藏  举报