# pmem **Repository Path**: movie0125/pmem ## Basic Information - **Project Name**: pmem - **Description**: 系统进程和文件缓存查看工具 - **Primary Language**: Rust - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-03-28 - **Last Updated**: 2022-04-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: Cache, file ## README # pmem #### 介绍 系统进程和文件缓存查看工具 #### 使用说明 ##### 打印进程内存使用情况 ``` $ pmpm proc -h pmem-proc Print process memory USAGE: pmem proc [OPTIONS] OPTIONS: -h, --help Print help information -n, --name Prints the memory of the named process The priority is higher than pid -p, --pid Print only the process's memory The priority is higher than top -t, --top Prints the top number of processes in memory ``` ##### 打印文件缓存使用情况 ``` $ pmem cache -h pmem-cache Print shared file cache USAGE: pmem cache [OPTIONS] OPTIONS: -h, --help Print help information -p, --pid Prints the process's file cache -t, --top Prints the top number of file cache ``` ## How to - 查询内存占用最高的10个进程 ``` $ sudo pmem proc -t 10 ...................................... : 进程ID : 进程名 : 内存 : :........:...............:...........: : 218980 : code : 287.85 MB : : 219223 : rls : 274.86 MB : : 219029 : code : 223.14 MB : : 216160 : chrome : 219.38 MB : : 238118 : chrome : 172.92 MB : : 215092 : system_server : 171.94 MB : : 214318 : uengine : 168.80 MB : : 216228 : chrome : 164.15 MB : : 218040 : code : 160.16 MB : : 214308 : kwin_x11 : 157.84 MB : :........:...............:...........: 进程总数 10 内存总和 1.95 GB ``` - 查询指定进程的共享文件缓存最高的10项 ``` $ sudo pmem cache -p 219029 -t 10 ........................................................................................... : 文件名 : 文件大小 : 缓存大小 : 缓存百分比 : :....................................................:...........:...........:............: : "/usr/share/code/code" : 123.74 MB : 104.00 MB : 84.05 : : "/usr/lib/x86_64-linux-gnu/libgtk-3.so.0.2404.1" : 6.93 MB : 5.67 MB : 81.75 : : "/usr/share/code/icudtl.dat" : 9.93 MB : 5.35 MB : 53.87 : : "/usr/lib/x86_64-linux-gnu/libc-2.28.so" : 1.74 MB : 1.74 MB : 100.00 : : "/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.5800.3" : 1.73 MB : 1.52 MB : 88.04 : : "/usr/lib/x86_64-linux-gnu/libm-2.28.so" : 1.51 MB : 1.51 MB : 100.00 : : "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25" : 1.50 MB : 1.44 MB : 95.83 : : "/usr/share/code/libffmpeg.so" : 2.63 MB : 1.38 MB : 52.37 : : "/usr/lib/x86_64-linux-gnu/libnss3.so" : 1.29 MB : 1.23 MB : 94.88 : : "/usr/lib/x86_64-linux-gnu/libepoxy.so.0.0.0" : 1.19 MB : 1.15 MB : 96.08 : :....................................................:...........:...........:............: 文件总数 10 缓存总和 124.98 MB ``` ## TODO ### 功能 - 支持监控数据收集功能,pmem作为后台进程,监控系统中所有进程内存使用情况,并将数据写入时序数据库,使用 grafana 查看 - 支持查看进程堆,栈,文件缓存,等细分内存使用情况。 - 支持查看内核相关内存使用情况。 - 支持 Restful API 接口设计标准及规范,提供API接口(支持json输出) - 支持输出整个系统内存使用情况报告(需要先设计好报告展现格式和关键字段) - 支持解析上面的报告,并用网页形式展现 - 支持解析上面的报告,并用命令行形式展现 - 支持日志级别打印 ### 性能 - 性能优化,使用 proc_maps 包的方法 get_process_maps 函数解析maps文件,得到很多暂时用不到的信息,浪费了性能 请自行实现解析进程 maps 信息的函数,并提供性能优化对比报告 - 性能优化,使用sysinfo包的方法 new_all 和processes 得到所有进程相关信息,得到很多暂时用不到的信息,浪费了性能 请自行实现解析进程 MEM 信息的函数,并提供性能优化对比报告