1、下载并安装hcache工具
备用地址:wget https://silenceshell-1255345740.cos.ap-shanghai.myqcloud.com/hcache
wget https://blog.tag.gg/soft/hcache
2、设置文件权限并移动到bin目录下。
至此,工具安装完成。chmod 755 hcache && mv hcache /usr/local/bin/
如何使用工具:
1、查看占用换成最大的5个进程:
显示如下:hcache -top 5
如图。 选项解释如下:root@blogtagggnew:~# hcache -top 5
+-------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+-----------+---------+
| Name | Size (bytes) | Pages | Cached | Percent |
|-------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+-----------+---------|
| /var/log/journal/20200914172502291423539425701795/system@84cfeba6e6924865b4a57d1fd00204ca-0000000000171758-000612ee2364512a.journal | 109051904 | 26624 | 18934 | 071.116 |
| /opt/threatbook/OneAV/OneAV/oneav | 15415808 | 3764 | 3764 | 100.000 |
| /www/server/mysql/bin/mysqld | 333463104 | 81412 | 1799 | 002.210 |
| /www/server/nginx/sbin/nginx | 16451296 | 4017 | 1391 | 034.628 |
| /usr/local/cloudmonitor/CmsGoAgent.linux-amd64 | 13701051 | 3345 | 1335 | 039.910 |
+-------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+-----------+---------+
- name:占用缓存的文件全路径
- size:文件大小
- pages:占了多少个Block
- Cached:缓存使用了多少个Block
- Percent:Cached 与 Pages的比值
显示如下:hcache -top 5 -bname
如图。 查看某进程的缓存使用情况。root@blogtagggnew:~# hcache -top 5 -bname
+-----------------------------------------------------------------------------------+----------------+------------+-----------+---------+
| Name | Size (bytes) | Pages | Cached | Percent |
|-----------------------------------------------------------------------------------+----------------+------------+-----------+---------|
| system@84cfeba6e6924865b4a57d1fd00204ca-0000000000171758-000612ee2364512a.journal | 109051904 | 26624 | 18843 | 070.774 |
| oneav | 15415808 | 3764 | 3764 | 100.000 |
| mysqld | 333463104 | 81412 | 1799 | 002.210 |
| CmsGoAgent.linux-amd64 | 13701051 | 3345 | 1335 | 039.910 |
| php-fpm | 10850360 | 2650 | 1118 | 042.189 |
+-----------------------------------------------------------------------------------+----------------+------------+-----------+---------+
输出如下:hcache -pid 536624
root@blogtagggnew:~# hcache -pid 536624
+---------------------------------------------------+----------------+------------+-----------+---------+
| Name | Size (bytes) | Pages | Cached | Percent |
|---------------------------------------------------+----------------+------------+-----------+---------|
| /usr/lib/x86_64-linux-gnu/libz.so.1.2.11 | 108936 | 27 | 27 | 100.000 |
| /usr/lib/x86_64-linux-gnu/libXpm.so.4.11.0 | 80768 | 20 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/liblzma.so.5.2.4 | 162264 | 40 | 39 | 097.500 |
| /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 | 104984 | 26 | 25 | 096.154 |
| /usr/lib/x86_64-linux-gnu/ld-2.31.so | 191504 | 47 | 47 | 100.000 |
| /usr/lib/x86_64-linux-gnu/libnss_files-2.31.so | 51856 | 13 | 13 | 100.000 |
| /usr/lib/x86_64-linux-gnu/libjbig.so.0 | 66568 | 17 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28 | 1952928 | 477 | 413 | 086.583 |
| /usr/lib/x86_64-linux-gnu/libpng16.so.16.37.0 | 223304 | 55 | 55 | 100.000 |
| /usr/lib/x86_64-linux-gnu/libuuid.so.1.3.0 | 30936 | 8 | 8 | 100.000 |
| /usr/lib/x86_64-linux-gnu/libfreetype.so.6.17.1 | 776264 | 190 | 156 | 082.105 |
| /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.12.0 | 285840 | 70 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libicudata.so.66.1 | 28046896 | 6848 | 0 | 000.000 |
| /www/server/nginx/sbin/nginx | 16451296 | 4017 | 758 | 018.870 |
| /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0 | 18688 | 5 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0 | 1293928 | 316 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libgd.so.3.0.5 | 410432 | 101 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.10 | 1799408 | 440 | 38 | 008.636 |
| /usr/local/lib/libluajit-5.1.so.2.0.4 | 462208 | 113 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libpthread-2.31.so | 157224 | 39 | 39 | 100.000 |
| /usr/lib/x86_64-linux-gnu/libdl-2.31.so | 18848 | 5 | 5 | 100.000 |
| /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0 | 166488 | 41 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libzstd.so.1.4.4 | 686160 | 168 | 103 | 061.310 |
| /usr/lib/x86_64-linux-gnu/libexpat.so.1.6.11 | 182560 | 45 | 42 | 093.333 |
| /usr/local/lib/libjemalloc.so.2 | 5367448 | 1311 | 33 | 002.517 |
| /usr/lib/x86_64-linux-gnu/libnss_systemd.so.2 | 239896 | 59 | 59 | 100.000 |
| /usr/lib/x86_64-linux-gnu/libwebp.so.6.0.2 | 420376 | 103 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0 | 202760 | 50 | 39 | 078.000 |
| /usr/lib/x86_64-linux-gnu/libicuuc.so.66.1 | 1976648 | 483 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libbsd.so.0.10.0 | 96728 | 24 | 24 | 100.000 |
| /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0 | 26800 | 7 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libjpeg.so.8.2.2 | 539352 | 132 | 124 | 093.939 |
| /usr/lib/x86_64-linux-gnu/libtiff.so.5.5.0 | 522936 | 128 | 0 | 000.000 |
| /usr/lib/x86_64-linux-gnu/libm-2.31.so | 1369384 | 335 | 335 | 100.000 |
| /usr/lib/x86_64-linux-gnu/libc-2.31.so | 2029592 | 496 | 496 | 100.000 |
+---------------------------------------------------+----------------+------------+-----------+---------+
文章评论 本文章有个评论