DF speed – Volume fill up speed – ddfddf-auto & ddf-auto-i script

Need to know how fast in Kilobytes per second or Megabytes per second you mount point or volume is filling up (or emptying). This script will inform you of just that.

Need to know the speed of a transfer, you can just measure how fast df’s used speed is changing for a certain volume and assume speed of transfer is analogous to the speed of the volume its filling up (of course there could be other things filling up or emptying the volume). This script can also be used to see how fast a volume is freeing space.

CATCH: not every copy of a file immediately updates the DF values. Seems that the sync function does it. But for those filesystems that update DF value reliably and continously this will work.

Volume is being filled up returns a positive speed value.
Volume being emptied, growing in free space, returns a negative speed value.

Its pretty simple algorithm, we just take df at one point in time, then at another and measure the difference. Since linux’s time resolution is only 1 second with “ date +$s ” (which gives seconds since the 1970s epoch), we must specify a delta time/difference in measurements in seconds. So a good delta time is like 2 seconds, but you can pick 5 seconds.

There are 3 scripts: ddf and ddf-auto

ddf should be used in conjunction with a while loop or watch also it can be manually run (it will tell you the difference in time since last run)
ddf-auto has the while loop built in, you get to pick the delta time in the argument (so you need to select volume name and delta time). ddf-auto-i is used in the same manner as ddf-auto meaning you need to specify volume name and the delta time, it gives you more information like inodes used and inodes difference (ddf and ddf-auto dont look at inodes). Also ddf-auto-i measures difference with respect to the start point (current value MINUS start value). Where as ddf and ddf-auto are measuring speed changes instantenously (current value MINUS last value a second or two ago)

Usage and examples of use are listed in the comments. Just make sure you choose a unique name for the first argument which sets the “device or mount point”, it has to be unique and it has to match how its seen in df, because the script greps for values from df’s output.

DDF SCRIPT – I saved mine as /sbin/ddf


DDF-AUTO SCRIPT – I saved mine as /sbin/ddf-auto


DDF-AUTO-I – I saved mine as /sbin/ddf-auto-i



I have an rsync job running from 1 volume to another doing a backup. I want to know the overall transfer speed (rsync only shows progress and speed per file). My destination volume is getting filled up and not the source, so its size will be changing – you have to identify which volume will have the changing size. You can do so by running “df” a couple times and notice which volume is changing. In my case I see that the volume /dev/mapper/vo-both (which is mounted to /mnt/both) is changing – and obviously I know this as thats where I instructed my rsync job to copy to.

The first argument with ddf and ddf-auto is the mount point or volume name as seen from df. The catch is that you have to select a unique name for the argument.

Running df, I see the following:


I want to monitor vo-both which is mounted to /mnt/both. So I could select “/dev/mapper/vo-both” for the first argument. Notice that I can’t select the mount point in this case because the mount point “/mnt/both” is also shared with the above mount point “/mnt/both/md127” and I dont want to monitor that devices df speed. You have to think of what grep will find, the mission is for grep to only find 1 entry. So If I select /mnt/both it will find 2 lines. However if I select /dev/mapper/vo-both it will find that 1 entry that I need. Notice that I can also just type “vo-both” because its still unique and it will only grep out the last line (and nothing extra).

– Meaning this will work (only 1 line matches the 1st argument in df):  # /sbin/ddf /dev/mapper/vo-both – This will also work (only 1 line matches the 1st argument in df):  # /sbin/ddf vo-both – But this will not work (more then 1 line matching in df):  # /sbin/ddf /mnt/both – This will not work as well (more then 1 line matching in df):  # /sbin/ddf both – Technically I can also use 2580272, because that is the total space of the volume and that will never change (unless I shrink or enlarge the volume) – this will work – however its not human readable# /sbin/ddf 2580272

So I will pick vo-both for the first argument so that I can monitor the device /dev/mapper/vo-both fill up speed (df speed).

For ddf I dont need to specify a time interval in the ddf arguments, but I do within the watch. I give it a 2 second interval with -n2 (this is watches argument)
# /sbin/ddf vo-both Again this would give me same results:
# /sbin/ddf /dev/mapper/vo-both

For ddf-auto I have to specify a time interval in the ddf-auto arguments (its the second argument), so I select 2 seconds, just by typing 2 for that argument. The first argument will be the same as the first argument on ddf.
# /sbin/ddf-auto vo-both 2 Again this would give me same results:
# /sbin/ddf-auto /dev/mapper/vo-both 2

NOTE: I put my ddf and ddf-auto in /sbin as I will be using them quiet often (I could of just put it in /usr/local/bin, but I was lazy and /sbin was shorter to type, and I didnt think of /bin at the time, which also would of worked)

Example output of ddf:

Example output ddf-auto:

Example output ddf-auto-i:


Leave a Reply

Your email address will not be published. Required fields are marked *