Is there a way to file the cause (or target file) of disk write operations in linux (RHEL6.1)?

2

1

I have a virtual machine with a php based application (in apache) on it, when looking at disk activity there is a constant 170kbps write when apache is running.

When we apply load then the performance of the server is cpu bound but this seems to be directly related to disk write IO jumps of 20-30x. The CPU usage graph mirrors the write disk access graph.

Any ideas?

JTew

Posted 2012-05-25T00:52:40.693

Reputation: 123

Answers

2

Two recommendations:

iotop is a handy program that shows you real-time I/O usage in a format like the top command. This should help you identify the script/binary thats doing all the I/O. I think this may already be installed on newer kernels, but yum may provide it on RHEL if you don't see it.

lsof is also helpful with I/O troubleshooting; it lists any open files.

UPDATE

If there is "constant" disk activity, then iotop should tell you which process(es) are the culprits. Regarding I/O transaction history: I don't believe IO history is logged anywhere in most Linux distros, but you can add a cron job.

As root, open up crontab with crontab -e and add these two lines:

* * * * * /bin/date >> /var/log/iotop; /usr/local/bin/iotop -bot --iter=3 -q >> /var/log/iotop
* * * * * /bin/date >> /var/log/lsof; /usr/bin/lsof -b -w >> /var/log/lsof

That dumps iotop and lsof output to a log every minute. Add a logrotate script for each to keep the files from taking up all your space, e.g.:

someuser@myhost:~> cat /etc/logrotate.d/lsof
/var/log/lsof {
  rotate 3
  weekly
  compress
  missingok
  notifempty
}

Banjer

Posted 2012-05-25T00:52:40.693

Reputation: 387

I think lsof is what I want, I'll try it to see if it shows me the open files. Is there anyway to get a tail of io operations including deletes? – JTew – 2012-05-28T20:43:20.167

Looks like you figured it out, but I added some info the my answer if you find it helpful. – Banjer – 2012-05-29T12:41:43.187

0

It appears that an unrelated background task was deleting the contents of the /tmp directory where php was being pre-compiled to. As a result the php pre-compile process started again resulting in constant disk activity.

JTew

Posted 2012-05-25T00:52:40.693

Reputation: 123

was the background task a custom cron job you created or something by default in RHEL 6? – Banjer – 2012-05-29T12:43:38.783