Skip to content

Instantly share code, notes, and snippets.

@smj10j
Last active January 21, 2017 02:02
Show Gist options
  • Save smj10j/7f342817b655dc33adf4b53d1d1f5322 to your computer and use it in GitHub Desktop.
Save smj10j/7f342817b655dc33adf4b53d1d1f5322 to your computer and use it in GitHub Desktop.
Monitor and print a disk's write speed by doing a simple comparison of the used space over time. Can be useful for network mounts
#!/usr/bin/env bash
DISK="Moody Mona" # Name of a directory mounted in /Volumes
INTERVAL=15
while true; do
s1=$(df -m | grep "$DISK" | awk '{print $3}')
echo "s1=$s1" >&2
sleep $INTERVAL
s2=$(df -m | grep "$DISK" | awk '{print $3}')
echo "s2=$s2" >&2
r=$(( (s2 - s1) / INTERVAL ))
echo "$DISK Write Rate: $r MB/S"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment