Skip to content

Instantly share code, notes, and snippets.

@alexyorke
Created December 31, 2016 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexyorke/e78bf6eb5412a3d2956a83db6f4768db to your computer and use it in GitHub Desktop.
Save alexyorke/e78bf6eb5412a3d2956a83db6f4768db to your computer and use it in GitHub Desktop.
Tracks how much data is written to your SSD everyday to prevent over-wearing and helps locate misbehaving apps
# grep for your hd (e.g. sda1) assumes 512kb blocks
# based on http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux
stat=$( awk '/sd/ {print $3"\t"$10 / 2 / 1024}' /proc/diskstats | sed 's/\s\+/ /g' | grep sda1 )
mbWritten=$(echo $stat | cut -d " " -f 2)
echo "Megabytes written (all time): $mbWritten"
# exercise for the reader: save value to file, and compare it to tomorrow to see how many mb's were written
# if there is more than, say, 1024 * 40 then you might want to track down the app that's writing too much
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment