有没有办法监控驱动器访问历史记录?

有没有办法监控驱动器访问历史记录?

我偶尔会遇到硬盘活动突然爆发的情况,这种情况会持续 10-20 秒,然后停止。我看到一些帖子暗示可能正在进行某种索引,但我不知道如何调查这种情况。

问题通常(但并非总是)发生在刚睡醒时。会有短暂的剧烈活动,然后就停止了。这个问题发生在一个在过去 4-5 年里没有太大变化的系统上,最近才开始出现,可能是在过去的 4-6 个月里。

刚刚安装了 fatrace,但它似乎只是实时的,我需要的是带有时间戳的历史记录,这样我就可以看到在某个时间访问了磁盘的内容。

答案1

我猜这是由于启动了过期的 cron 作业造成的:其中有许多作业应该每天、每周、每月运行。只需看一下/etc/cron.*

sh@balrog:~$ ls -ld /etc/cron.*
drwxr-xr-x 2 root root 4096 Apr 26  2018 /etc/cron.d
drwxr-xr-x 2 root root 4096 Apr  7 10:04 /etc/cron.daily
drwxr-xr-x 2 root root 4096 Apr 26  2018 /etc/cron.hourly
drwxr-xr-x 2 root root 4096 Apr 26  2018 /etc/cron.monthly
drwxr-xr-x 2 root root 4096 Jan  7 11:12 /etc/cron.weekly
sh@balrog:~$ ls -l /etc/cron.daily
total 56
-rwxr-xr-x 1 root root  311 Mai 29  2017 0anacron
-rwxr-xr-x 1 root root  376 Nov 20  2017 apport
-rwxr-xr-x 1 root root 1478 Apr 20  2018 apt-compat
-rwxr-xr-x 1 root root  314 Jan 17  2018 aptitude
-rwxr-xr-x 1 root root  355 Dez 29  2017 bsdmainutils
-rwxr-xr-x 1 root root 1176 Nov  2  2017 dpkg
-rwxr-xr-x 1 root root  372 Aug 21  2017 logrotate
-rwxr-xr-x 1 root root 1065 Apr  7  2018 man-db
-rwxr-xr-x 1 root root 6574 Apr  6 14:26 opera-browser
-rwxr-xr-x 1 root root  249 Jan 25  2018 passwd
-rwxr-xr-x 1 root root 3477 Feb 21  2018 popularity-contest
-rwxr-xr-x 1 root root  246 Mär 21  2018 ubuntu-advantage-tools
-rwxr-xr-x 1 root root  214 Jul 12  2013 update-notifier-common

当它真正cron运行这些作业时(现在它可能正在使用 systemd 计时器单元),它应该在夜间运行,而那时没有人需要那么多的计算能力。

但是家里或办公室的电脑在夜间不会运行,所以创建了一种后备机制,让这些后台作业在机器启动后(重启或恢复后)运行一段时间。

有些工作完成得非常快,你几乎感觉不到它们;其他工作,比如更新定位数据库,可能需要一段时间。

如果您想要使用该locate命令,该命令会扫描所有文件系统。这让我很恼火,所以我删除了该软件包,因为我locate从来没用过它(find它功能强大得多)。

您所描述的听起来很像是同一个问题。


回到您的具体问题,当这些进程运行时,很难发现它们。当它启动时,您可以使用命令top(或桌面上的 GUI 对应命令)试试看哪些异常进程处于活动状态。但如果它们确实主要进行磁盘 I/O 操作,很少进行计算,您可能无法发现它们。

pstree也可能有帮助,因为它显示了流程层次结构。

还有iotopdstat(在我看来帮助不大)和旧的vmstat(从来不太喜欢那个)。

相关内容