Created
December 30, 2012 12:22
-
-
Save friskfly/4412600 to your computer and use it in GitHub Desktop.
python 监控CPU wmi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import wmi | |
import time | |
c = wmi.WMI() | |
while True: | |
for cpu in c.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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment