简体   繁体   English

如何找出正在读取磁盘的进程?

[英]How to find out which process is reading disk?

I'm using a GCP VM, from time to time, I lost ssh connection to this VM.我正在使用 GCP 虚拟机,有时我会失去与该虚拟机的 ssh 连接。 After some investigation, I found that during the time I cannot ssh to the VM, the disk IO read is very high, nearly 100MB/s.经过一番调查,我发现在我无法 ssh 到 VM 期间,磁盘 IO 读取非常高,接近 100MB/s。

在此处输入图像描述

I'm pretty sure I'm not running any process that need do disk IO.我很确定我没有运行任何需要磁盘 IO 的进程。 So I need to find out which process did this.所以我需要找出是哪个进程做到了这一点。

How can I do it?我该怎么做? I checked logs in /var/log, and there's no suspicious logs.我检查了 /var/log 中的日志,没有可疑的日志。

Since I cannot log into the VM when the reading happens, I need some way to put it in background.由于在读取时无法登录虚拟机,因此我需要某种方式将其置于后台。

You could use something like iotop --only periodically (cron for example) to see what process is consuming IO.您可以定期使用iotop --only类的东西(例如 cron)来查看正在消耗 IO 的进程。 You should be able to install iotop via your package manager ( apt , yum , ...).您应该能够通过您的 package 管理器( aptyum 、...)安装iotop See this link:请参阅此链接:

https://www.tecmint.com/iotop-monitor-linux-disk-io-activity-per-process/ https://www.tecmint.com/iotop-monitor-linux-disk-io-activity-per-process/

In case the link above goes down, you can add something like this in the crontab:如果上面的链接失效,您可以在 crontab 中添加如下内容:

* * * * * root iotop -botqqq --iter=3 >> /var/log/iotop

to check IO usage per process every minute (you can change every 5 minutes, every 10 minutes, etc.).每分钟检查每个进程的 IO 使用情况(您可以每 5 分钟、每 10 分钟等更改一次)。 Be careful though that you don't fully fill your disk with /var/log/iotop (rotate logs or something else).请注意,尽管您没有用/var/log/iotop (旋转日志或其他东西)完全填满磁盘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM