psutil模块

首先需要先导入psutil模块
pip install psutil
'''

* coding=utf8 *

import psutil

CPU

print psutil.cpu_times(percpu = False)
print psutil.cpu_percent(interval=None, percpu = True)
print psutil.cpu_count(logical=True)
print psutil.cpu_stats()
print psutil.cpu_freq(percpu=False)

内存

print psutil.virtual_memory()
print psutil.swap_memory()

磁盘

print psutil.disk_partitions(all=False)
print psutil.disk_usage(r"c:\")
print psutil.disk_io_counters(perdisk=False, nowrap=True)

网络

print psutil.net_io_counters(pernic=False)
print psutil.net_connections(kind='inet')
print psutil.net_if_addrs()
print psutil.net_if_stats()

传感器

print psutil.sensors_temperatures(fahrenheit=False)
print psutil.sensors_fans()
print psutil.sensors_battery()

其他

print psutil.boot_time()/1000/60/60
print psutil.users()
'''

推荐阅读更多精彩内容