• hcache查看系统缓存


     

    hcache是基于pcstat的,pcstat可以查看某个文件是否被缓存和根据进程pid来查看都缓存了哪些文件。hcache在其基础上增加了查看整个操作系统Cache和根据使用Cache大小排序的特性。

    安装

    # wget https://silenceshell-1255345740.cos.ap-shanghai.myqcloud.com/hcache
    
    # chmod 755 hcache ;mv hcache /usr/local/bin/

    使用

    1、查看占用缓存最多的三个文件

    # hcache -top 3
    2021/06/03 21:01:28 skipping "/tmp/hsperfdata_test/531": could not open file for read: open /tmp/hsperfdata_test/531: no such file or directory
    +------------------------------------------------------------------+----------------+------------+-----------+---------+
    | Name                                                             | Size (bytes)   | Pages      | Cached    | Percent |
    |------------------------------------------------------------------+----------------+------------+-----------+---------|
    | /home/test/softwares/jdk1.8.0_191/jre/lib/rt.jar                 | 66346586       | 16198      | 4559      | 028.145 |
    | /home/test/softwares/jdk1.8.0_191/jre/lib/amd64/server/libjvm.so | 17022752       | 4156       | 3734      | 089.846 |
    | /etc/udev/hwdb.bin                                               | 7780559        | 1900       | 958       | 050.421 |
    +------------------------------------------------------------------+----------------+------------+-----------+---------+

    结果展示含义如下:

    • name:占用缓存的文件全路径
    • size:文件大小
    • pages:占了多少个Block
    • Cached:缓存使用了多少个Block
    • Percent:Cached 与 Pages的比值

    上面命令显示的是文件全路径,可以使用-bname选项,只显示文件名

    # hcache -top 3 -bname
    2021/06/03 21:11:44 skipping "/tmp/hsperfdata_test/531": could not open file for read: open /tmp/hsperfdata_test/531: no such file or directory
    +-----------+----------------+------------+-----------+---------+
    | Name      | Size (bytes)   | Pages      | Cached    | Percent |
    |-----------+----------------+------------+-----------+---------|
    | rt.jar    | 66346586       | 16198      | 4559      | 028.145 |
    | libjvm.so | 17022752       | 4156       | 3734      | 089.846 |
    | hwdb.bin  | 7780559        | 1900       | 958       | 050.421 |
    +-----------+----------------+------------+-----------+---------+

    查看进程的缓存使用

    # hcache -pid 1397
    +-----------------------+----------------+------------+-----------+---------+
    | Name                  | Size (bytes)   | Pages      | Cached    | Percent |
    |-----------------------+----------------+------------+-----------+---------|
    | libm-2.23.so          | 1088952        | 266        | 185       | 069.549 |
    | libstdc++.so.6.0.21   | 1566440        | 383        | 346       | 090.339 |
    | libz.so.1.2.8         | 104824         | 26         | 26        | 100.000 |
    | libdl-2.23.so         | 14608          | 4          | 4         | 100.000 |
    | libwrap.so.0.7.6      | 36632          | 9          | 9         | 100.000 |
    | libaio.so.1.0.1       | 5512           | 2          | 2         | 100.000 |
    | libnss_compat-2.23.so | 35688          | 9          | 9         | 100.000 |
    | libnsl-2.23.so        | 93128          | 23         | 23        | 100.000 |
    | libc-2.23.so          | 1864888        | 456        | 456       | 100.000 |
    | libcrypt-2.23.so      | 39224          | 10         | 10        | 100.000 |
    | librt-2.23.so         | 31712          | 8          | 8         | 100.000 |
    | liblz4.so.1.7.1       | 96360          | 24         | 24        | 100.000 |
    | libgcc_s.so.1         | 89696          | 22         | 22        | 100.000 |
    | libpthread-2.23.so    | 138696         | 34         | 34        | 100.000 |
    | libnss_nis-2.23.so    | 47648          | 12         | 12        | 100.000 |
    | libnuma.so.1.0.0      | 43936          | 11         | 11        | 100.000 |
    | ld-2.23.so            | 162632         | 40         | 40        | 100.000 |
    | mysqld                | 24754056       | 6044       | 4051      | 067.025 |
    | libnss_files-2.23.so  | 47600          | 12         | 12        | 100.000 |
    +-----------------------+----------------+------------+-----------+---------+
  • 相关阅读:
    【数据结构】KMP算法
    【数据结构】银行问题
    ejs模板渲染页面
    node的知识点
    http搭建服务器
    http接收页面传递的数据
    http模块
    node的http模块
    node的fs模块
    base.css
  • 原文地址:https://www.cnblogs.com/zh-dream/p/14848152.html
Copyright © 2020-2023  润新知