hcache是基于pcstat的,pcstat可以查看某个文件是否被缓存和根据进程pid来查看都缓存了哪些文件。hcache在其基础上增加了查看整个操作系统Cache和根据使用Cache大小排序的特性
下载hcache
wget https://silenceshell-1255345740.cos.ap-shanghai.myqcloud.com/...
chmod 755 hcache ; mv hcache /usr/bin
查看占用缓存最多的三个文件
# hcache -top 3

+----------------------------------------------+----------------+------------+-----------+---------+
| Name                                         | Size (bytes)   | Pages      | Cached    | Percent |
|----------------------------------------------+----------------+------------+-----------+---------|
| /opt/google/chrome/chrome                    | 216152840      | 52772      | 47108     | 089.267 |
| /usr/sbin/dockerd                            | 77613032       | 18949      | 16459     | 086.859 |
| /usr/lib/electronic-wechat/electronic-wechat | 69190688       | 16893      | 12788     | 075.700 |
+----------------------------------------------+----------------+------------+-----------+---------+

结果展示含义如下:
name:占用缓存的文件全路径
size:文件大小
pages:占了多少个Block
Cached:缓存使用了多少个Block
Percent:Cached 与 Pages的比值
上面命令显示的是文件全路径,可以使用-bname选项,只显示文件名
# hcache -top 3 -bname

+-------------------+----------------+------------+-----------+---------+
| Name              | Size (bytes)   | Pages      | Cached    | Percent |
|-------------------+----------------+------------+-----------+---------|
| chrome            | 216152840      | 52772      | 47120     | 089.290 |
| dockerd           | 77613032       | 18949      | 16459     | 086.859 |
| electronic-wechat | 69190688       | 16893      | 12815     | 075.860 |
+-------------------+----------------+------------+-----------+---------+

查看进程的缓存使用
# hcache -pid 1356


Rocky
1 声望3 粉丝