我是使用的git从github拉取下代码,然后重新编译的, 因为此项目是go语言写的,所以编译时需要安装go语言
如下命令下载代码,或者直接下载zip压缩包,资源在 “此目录下文档中所用的资源” 目录中
git clone git@github.com:silenceshell/hcache.git
进入主目录,编译,然后将编译后的文件拷贝到/usr/local/bin目录下,即可使用
cd hcache
make build
sudo cp hcache /usr/local/bin/
使用:
hcache <-json <-pps>|-terse|-default> <-nohdr> <-bname> file file file
-json output will be JSON
-pps include the per-page information in the output (can be huge!)
-terse print terse machine-parseable output
-default print ascii tables
-histo print a histogram using unicode block characters
-nohdr don't print the column header in terse or default format
-bname use basename(file) in the output (use for long paths)
-plain return data with no box characters
-unicode return data with unicode box characters
-pid int show all open maps for the given pid
-top int show top x cached files
$ hcache --top 10
[sudo] password for silenceshell:
+----------------------------------------------------------------------------------+----------------+------------+-----------+---------+
| Name | Size (bytes) | Pages | Cached | Percent |
|----------------------------------------------------------------------------------+----------------+------------+-----------+---------|
| /opt/google/chrome/chrome | 114911208 | 28055 | 25457 | 090.740 |
| /usr/share/code/code | 67688720 | 16526 | 12274 | 074.271 |
| /home/silenceshell/Software/pycharm-community-2016.2/lib/pycharm.jar | 95177431 | 23237 | 11325 | 048.737 |
| /opt/atom/atom | 62641344 | 15294 | 10578 | 069.164 |
| /usr/bin/dockerd | 39121168 | 9552 | 7103 | 074.361 |
| /home/silenceshell/Software/pycharm-community-2016.2/jre/jre/lib/amd64/libjfxwebkit.so | 57455824 | 14028 | 6625 | 047.227 |
| /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.10.2 | 36462184 | 8902 | 6316 | 070.950 |
| /usr/lib/beyondcompare/BCompare | 30640160 | 7481 | 5505 | 073.586 |
| /usr/bin/SecureCRT | 29524560 | 7209 | 4806 | 066.667 |
| /usr/share/code/libnode.so | 21135976 | 5161 | 4588 | 088.898 |
+----------------------------------------------------------------------------------+----------------+------------+-----------+---------+
$
$ hcache --top 3 --bname
+-------------+----------------+------------+-----------+---------+
| Name | Size (bytes) | Pages | Cached | Percent |
|-------------+----------------+------------+-----------+---------|
| chrome | 114911208 | 28055 | 25476 | 090.807 |
| pycharm.jar | 95177431 | 23237 | 11479 | 049.400 |
| atom | 62641344 | 15294 | 10578 | 069.164 |
+-------------+----------------+------------+-----------+---------+
$
$ lsof /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.10.2
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
quiterss 20630 silenceshell mem REG 8,5 36462184 3936610 /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.10.2
根据上面github给的示例,我们可以发现常用的两个命令为:
在root用户下使用:
1.显示top n的缓存目录
hcache --top 10
2.显示top n 的缓存目录的基本信息,包括大小
hcache --top 3 --bname