【问题标题】:Is it possible to monitor all write access to the filesystem of all process under linuxlinux下是否可以监控所有进程对文件系统的所有写访问
【发布时间】:2018-11-29 11:37:26
【问题描述】:

linux下是否可以监控所有进程对文件系统的所有写访问?

我有一些不同的挂载文件系统。其中很多是临时文件。

我对除 tempfs、devtmpfs 等之外的所有对根文件系统的写入感兴趣。

我正在寻找可以输出的东西:<PID xy> write n Bytes to /targe/filepath。 什么监控工具可以列出所有这些写入系统调用?可以按挂载点过滤吗?

【问题讨论】:

标签: linux logging filesystems system-calls


【解决方案1】:

iotop(内核版本 2.6.20 或更高版本)或dstat 可以帮助您。例如。 iotop -o -b -d 10 就像在这个 similar thread 中讨论的一样。

【讨论】:

    【解决方案2】:

    /proc/diskstats 包含所有块设备的数据。

    https://www.kernel.org/doc/Documentation/iostats.txt

      The /proc/diskstats file displays the I/O statistics of block devices. Each line contains the following 14 fields:
                 1 - major number
                 2 - minor mumber
                 3 - device name
                 4 - reads completed successfully
                 5 - reads merged
                 6 - sectors read
                 7 - time spent reading (ms)
                 8 - writes completed
                 9 - writes merged
                10 - sectors written
                11 - time spent writing (ms)
                12 - I/Os currently in progress
                13 - time spent doing I/Os (ms)
                14 - weighted time spent doing I/Os (ms)
                For more details refer to Documentation/iostats.txt
    

    【讨论】:

      【解决方案3】:

      您可以编写SystemTap 脚本来监控文件系统操作。也许你可以访问Brendan D. Gregg's blog,那里有很多监控工具。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多