#!/usr/bin/env python
# -*- coding: utf-8 -*-
import wmi
import time
def cpu_mem():
c = wmi.WMI()
for processor in c.Win32_Processor():
print ("Processor ID: %s" % processor.DeviceID )
print( "Process Name: %s" % processor.Name.strip() )
for Memory in c.Win32_PhysicalMemory():
print( "Memory Capacity: %.fMB" %(int(Memory.Capacity)/1048576) )
def cpu_use():
c = wmi.WMI()
for i in range(1,3): # 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(3)
def main():
cpu_mem()
cpu_use()
取消
评论