#LOG:
# test to check CPU ,memory and process state
# built time 2017-05-19
# coder:ly
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import time
import psutil
import sys
import atexit
#the process name
PROCESS_NAME1="dwm.exe"
PROCESS_NAME2="QQ.exe"
PROCESS_NAME3="WeChat.exe"
PROCESS_NAME4="wininit.exe"
PROCESS_NAME5="360Tray.exe"
PROCESS_NAME6="conhost.exe"
#function of cpu total state
def GetCPUstate(time_count=1): #cpu物理个数 + cpu总使用率
return (str(psutil.cpu_count(logical=False))+"-"+str(psutil.cpu_percent(time_count,0)) + "%")
#function of evryone state
def GetCPUsatus(time_count=1): #每个cpu的使用率
return (str(psutil.cpu_percent(time_count,1)) + "%")
#function of memory state
def GetMemorystate():
phymem=psutil.virtual_memory()
string =str(int(phymem.tot
python 获取CPU、内存、硬盘、进程状态信息 代码
最新推荐文章于 2024-05-01 19:45:39 发布