在最近升级到 Fedora 15 后,我发现许多工具失败并出现以下错误:
tail: inotify resources exhausted
tail: inotify cannot be used, reverting to polling
Run Code Online (Sandbox Code Playgroud)
这不仅仅是tail报告 inotify 的问题。有没有办法询问内核以找出正在消耗 inotify 资源的进程?当前与 inotify 相关的sysctl设置如下所示:
fs.inotify.max_user_instances = 128
fs.inotify.max_user_watches = 8192
fs.inotify.max_queued_events = 16384
Run Code Online (Sandbox Code Playgroud) 我inotifywait用于放置文件的事件触发器。
当很多文件被 观看时inotifywait,当max_user_watches超过时,会出现以下错误。
因 inotify 监视而终止。#012考虑增加 /proc/sys/fs/inotify/max_user_watches
需要调整/proc/sys/fs/inotify/max_user_watches,但是可以查看当前文件监视号吗?
有没有办法像文件描述符中的 file-nr一样检查?
我有一个小脚本,列出了每个进程的 inotify 监视数量。这通常能让我得到我想要的东西,但现在我想知道哪些文件正在被监视。我认为这是可能的,并且inotify 监视对应于 inotify 实例监视的文件?
我还假设我可以基于该脚本中当前的内容进行构建。例如,
sudo find /proc/*/fd -lname anon_inode:inotify | cut -d "/" -f 3
Run Code Online (Sandbox Code Playgroud)
inotify获取带有文件描述符的进程列表。如果我查看其中一个文件描述符的信息,我会得到我假设的文件句柄/监视列表:
$ sudo cat /proc/50679/fdinfo/19
pos: 0
flags: 00
mnt_id: 15
inotify wd:8 ino:640001 sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:01006400feaad211
inotify wd:7 ino:a08da sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:da080a0094019e8f
inotify wd:6 ino:840003 sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:030084005ae9e3df
inotify wd:5 ino:840002 sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:020084000d506c1f
inotify wd:4 ino:840001 sdev:800001 mask:3cc ignored_mask:0 …Run Code Online (Sandbox Code Playgroud)