5

I want metrics for how much writing and reading have been done to a folder.

vmstat -d gives metrics at the whole disk level. iotop will give per process rw stats.

But how can I find out how much writing has been done to a folder or file?

depquid
  • 3,801
  • 1
  • 20
  • 34
rjt
  • 377
  • 1
  • 4
  • 15
  • 1
    Can't you compare the outputs of two different `du -sx` invocations? – Bratchley Dec 19 '14 at 23:41
  • 3
    Related / possible duplicates: [How can I monitor disk I/O in a particular directory ?](http://unix.stackexchange.com/q/9520), [How to monitor I/O stream in a particular Linux directory or file ?](http://unix.stackexchange.com/q/62121) – don_crissti Dec 20 '14 at 01:24
  • You may want to clarify what *"how much writing"* means for you. Difference between the directory sizes before and after writing? Amount of data sent to the underlying block device? – peterph Dec 20 '14 at 19:41
  • @don_crissti, one of those answers involved loopback mounting the directory in question - gotta love the simplicity of it. – rjt Jan 03 '15 at 17:53
  • @peterph, one movtivation is estimating SSD longevity due to caching proxy server rewrites. Amount of data sent to an underlying block device due to /var/proxy/cache/, but not not /var/log/. – rjt Jan 03 '15 at 18:04

1 Answers1

0

Given the clarification in the comment - the need of knowing how much data is being sent to the underlying block device (e.g. for the purposes of logging activity on SSD) - you'd need to check this in the file system driver and below (which usually is part of the kernel). Note, that just writing to a file doesn't mean the data gets really sent or even written to the device - there usually is lots of caching between the write() system call in user space and the actual bits making it into the wires connecting the hard drive to the controller.

peterph
  • 30,520
  • 2
  • 69
  • 75