Skip to content

Instantly share code, notes, and snippets.

@fstern
Last active May 28, 2017 16:49
Show Gist options
  • Save fstern/cdb54c8c3cd2c7f90054dc8182bdc0c7 to your computer and use it in GitHub Desktop.
Save fstern/cdb54c8c3cd2c7f90054dc8182bdc0c7 to your computer and use it in GitHub Desktop.
dm-cache status shell
#!/bin/bash
set -eo pipefail
if [ -z "$1" ]; then
echo "Usage: $0 <dm-cache device>"
exit 1
fi
/sbin/dmsetup status $1 | \
awk '{ rr = ($8/($8+$9))*100 ; wr = ($10/($10+$11))*100; print "meta: " $5 "\ncache: " $7 "\nread: "$8"/"$9, rr"% Hit\nwrite: "$10"/"$11, wr"% Hit\nmove: "$13"/"$12" (promote/demote)\ndirty: "$14 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment