python的pstuil模块使用方法总结
2019-07-26 10:51
776 查看
代码
import psutil print(dir(psutil)) # 查看逻辑cpu的个数 print(psutil.cpu_count()) # 查看物理cpu的个数 print(psutil.cpu_count(logical=False)) # 查看cpu的用户时间,系统时间,空闲时间,中断时间 print(psutil.cpu_times()) # 统计每个cpu的使用率 print(psutil.cpu_percent(interval=2,percpu=True)) # 统计真个cpu的使用率 print(psutil.cpu_percent(interval=2,percpu=False)) # 统计内存的使用情况 print(psutil.virtual_memory()) # 统计某个磁盘的使用情况 print(psutil.disk_usage(path="d:")) # 统计磁盘的io情况 print(psutil.disk_io_counters()) # 统计系统的根目录的信息,包括device,挂载点,文件系统类型 print(psutil.disk_partitions()) # 网卡的io情况 print(psutil.net_io_counters()) # 网卡信息 print(psutil.net_if_addrs()) # 网卡状态 print(psutil.net_if_stats()) # 网卡的连接情况 print(psutil.net_connections()) # 系统中所有的进程 print(psutil.pids()) # 判断某个进程是否存在 print(psutil.pid_exists(0)) # 获取某个进程的对象 p = psutil.Process(436) # 打印该进程的名字 print(p.name()) # 打印该进程一些信息,比如进程名字,id,启动时间 print(p.cpu_times) # 打印这个进程的占用cpu的使用时间 print(p.cpu_times()) # 打印这个进程的内存使用情况 print(p.memory_info()) # 打印这个进程启动的线程的数量 print(p.num_threads()) # 打印这个进程开启的线程的信息 print(p.threads())
以上就是本文的全部内容,希望对大家的学习有所帮助
您可能感兴趣的文章:
相关文章推荐
- python urllib2模块使用方法总结
- python simplejson模块的使用方法
- Python 模块paramiko简单使用方法
- 在Python中使用glob模块查找文件路径的方法
- 在python中使用cx_Oracle模块出现“DLL Load failed”的处理方法
- Python random模块(获取随机数)常用方法和使用例子
- Python使用xlrd模块操作Excel数据导入的方法
- python使用xlrd模块读写Excel文件的方法
- Python 模块paramiko简单使用方法
- python解析模块(ConfigParser)使用方法
- Python学习笔记之os模块使用总结
- python使用xlrd模块读写Excel文件的方法
- 关于使用python logging模块的几点总结
- 一波神奇的Python语句、函数与方法的使用技巧总结
- Python时间模块datetime、time、calendar的使用方法
- python使用wmi模块获取windows下硬盘信息的方法
- Python 中文分词工具 ——结巴分词的使用方法总结
- paip.python pyqt 加载ui 方法使用connect总结attilax
- Python optionParser模块的使用方法
- Python random模块(获取随机数)常用方法和使用例子