对于我正在监视的PHP网站,我需要查看每次浏览器发出请求时都使用了哪些文件。
我想过使用find . -type f -amin 1 find . -type f -amin 1 。
我得到所有在最后一分钟被读取的文件(这是一个发展中的服务器,所以只有我使用的网站)。
我负责从挂载点删除noatime属性。
但是一定有其他的东西阻止了内核读取磁盘上的实际文件,因为读取文件时访问时间并没有被更新。
我想它一定是从内存中检索文件的文件系统caching。
有没有办法在特定的目录下禁用文件caching? (public_html在我的情况)
另外我读了一些地方,有挂载属性,显然禁用文件caching在这个挂载点,但我不知道。
为什么不看apache日志? 它列出了每个访问时间戳的文件以及访问者。
如果您必须使用atime,请在stat系统调用的维基百科页面上注意以下内容:
Linux内核开发人员IngoMolnár曾经说过:“也许是所有时代最愚蠢的Unixdevise理念”,并补充说:“想一想:对于从磁盘读取的每一个文件,让我们做一个…写入磁盘!而且,对于每个已经被caching的文件以及从caching中读取的文件,都要写入磁盘!'“他进一步强调了性能的影响:
atime更新是迄今为止Linux最大的I / O性能缺陷。 摆脱一次更新会给我们更多的日常Linux性能比过去10年所有的pagecache加速, 加起来 。
当前版本的Linux支持四种安装选项,可以在fstab中指定:
strictatime (formerly atime, and formerly the default; strictatime as of 2.6.30) – always update atime relatime ("relative atime", introduced in 2.6.20 and the default as of 2.6.30) – only update atime under certain circumstances (explained below) nodiratime – never update atime of directories, but do update atime of other files noatime – never update atime of any file or directory; implies nodiratime; highest performance, but least compatible
对于我正在监视的PHP网站,我需要查看每次浏览器发出请求时都使用了哪些文件。
除非我错过了一些东西,否则你可以简单地尾巴服务器日志。
对于Apache:
tail -f /var/log/httpd/access_log
如果PHP正在读取未包括在浏览器请求中的其他文件(包括诸如此类),则可以打开审计。
auditctl -w /path/to/watch -pr -k php-access
你只会对PHP的读取感兴趣。
ausearch -k php-access -ui <uid php uses>