http://psutil.readthedocs.io/en/latest/ 详细用例
1、CPU
1 psutil.cpu_times(percpu=False)
返回cpu使用时间元祖。若percpu=True,返回各个CPU的使用情况列表。
1 psutil.cpu_percent(interval,percpu) #返回CPU利用率 2 psutil.cpu_times_percent(interval=None, percpu=False) 3 psutil.cpu_count(logical=True) #返回系统逻辑CPU 4 psutil.cpu_stats() #返回CPU的统计信息 5 psutil.cpu_freq(percpu=False) #返回CPU的频率
2、内存
1 psutil.virtual_memory() #返回系统内存使用情况的统计信息 2 psutil.swap_memory() #返回系统交换内存统计信息
3、磁盘
1 psutil.disk_partitions(all=False) #返回所有挂载的磁盘设备,包括设备、挂载点喝文件系统元祖的列表 2 psutil.disk_usage(path) #返回磁盘统计信息 3 psutil.disk_io_counters(perdisk=False, nowrap=True) #返回磁盘IO统计信息
4、网络
1 psutil.net_io_counters(pernic=False) #返回系统网络IO统计信息 2 psutil.net_connections(kind='inet') #返回系统socket连接 3 psutil.net_if_addrs() #返回网卡绑定的IP、子网掩码、广播地址 4 psutil.net_if_stats() #返回网卡的相关信息
5、传感器
1 psutil.sensors_temperatures(fahrenheit=False) #返回硬件的温度 2 psutil.sensors_fans() #返回硬件风扇速度 3 psutil.sensors_battery() #返回电池状态
6、其他
1 psutil.boot_time() #系统开机时间 2 psutil.users() #连接系统的用户列表
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有