#!/usr/bin/env python # coding:utf-8 import psutil total_cpu=psutil.cpu_times().user+psutil.cpu_times().idle user_cpu=psutil.cpu_times().user cpu_syl=user_cpu/total_cpu*100 mem = psutil.virtual_memory() #使用psutil.virtual_memory方法获取内存完整信息 mem_total=mem.total mem_used=mem.used mem_syl=mem_used/float(mem_total)*100 dis_syl= psutil.disk_usage(‘/‘).used/float (psutil.disk_usage(‘/‘).total)*100 print "CPU使用率",cpu_syl,"内存使用率",mem_syl,"磁盘使用率",dis_syl
时间: 2024-10-05 06:15:56