【问题标题】: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
【解决方案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