Skip to content

Instantly share code, notes, and snippets.

@friskfly
Created December 30, 2012 12:22
Show Gist options
  • Save friskfly/4412600 to your computer and use it in GitHub Desktop.
Save friskfly/4412600 to your computer and use it in GitHub Desktop.
python 监控CPU wmi
#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