I’m looking for a way to get the amount of data written to my disk over a period of time.

Specifically, at the end of the day, I would like to be able to find out how many total bytes have been written to my disk over the course of the day.

I’ve been searching for a solution but haven’t had any luck yet. I thought I came close with iostat, but that seems to only monitors current activity. I suppose I’m looking for something that can analyze past activity.

  • This is not directly related to your question per see, but have you looked into how to measure traffic across a network? Maybe if you search along those lines you might bump into info regarding to how to do the same on internal/external drives? Just an idea. – arch-abit Jan 16 '15 at 5:16

You say iostat only monitors current activity, but it is a very flexible/robust tool with lots of options. For example you can achieve your exact goal by following these simple steps.

First, open up the Mac OS X “Terminal” and run this command you can get a list of connected disks:

diskutil list

On my system the output is something like this:

   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS HardDisk                499.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS HardDisk_BACKUP         120.4 GB   disk1s2
   3:                  Apple_HFS Storage_1               1.9 TB     disk1s3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS Storage_2               2.0 TB     disk2s2

Now look at the partitions to see the disk you wish to check, but make note of the parent /dev/disk0, /dev/disk1, /dev/disk2, etc… disk/device numbers that are displayed. Let’s assume you want to check the data transferred to disk0; so enter the following iostat command like so:

iostat -Id disk0

The output on my Mac OS X 10.9.5 system is this:

 KB/t xfrs   MB 
17.12 1277872 21364.96 

That line of data reflects data transfer statistics from the moment the device was mounted to the moment the iostat command was run. The two options set for iostat are as follows; the text is taken directly from the man page you can review by typing in man iostat from the command line:

  • -d: Display only device statistics. If this flag is turned on, only device statistics will be displayed, unless -C or -U or -T is also specified to enable the display of CPU, load average or TTY statistics.

  • -I: Display total statstics for a given time period, rather than average statistics for each second during that time period.

And the three magic numbers returned—described as KB/t, xfrs and MB —are broken down as follows:

  • KB/t: kilobytes per transfer
  • xfrs: total number of transfers
  • MB: total number of megabytes transferred

And if you want to monitor in realtime—such as an interval of every 3 seconds—you could run this command with the -w flag:

iostat -Idw 3 disk0

The output on my Mac OS X 10.9.5 system is as follows:

 KB/t xfrs   MB 
17.13 1279283 21396.20 
 8.49  74  0.61 
 8.49  74  0.61 
 8.49  74  0.61 
29.33 193  5.53 
62.97 219 13.47 
50.51 294 14.50 

The first number is like the first example; cumulative up to the moment the command was run. The next items are updates every 3 seconds. The first 3 items are the disk basically near rest. The next 3 items with higher numbers fluctuating up and down reflect me opening up the drive in the “Finder” and browsing around a bit for this example.

If you wanted to you could integrate these iostat commands in a Bash script and maybe run them in a cron job, but that would be out of the scope of this question and answer thread.

  • 1
    Thanks very much for the very detailed reply Jake, this was helpful. – mmgg Jan 16 '15 at 22:14

Activity Monitor. [Applications/Utilities.]

Disk Tab.

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.