Last active
August 29, 2015 14:23
-
-
Save sling00/c49dc1d2a8e12e52e1cb to your computer and use it in GitHub Desktop.
dfree-bsd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Originally by stanislavs from post | |
#http://stanislavs.org/reporting-correct-space-usage-for-samba-shared-zfs-volumes/#comment-2443 | |
#Used some updated code from github user umito / Peter on that site to clean up the non zfs code. | |
MYDIR=`readlink -f $PWD` | |
MYDIR2=`df -h $MYDIR | tail -1 | awk '{print $6}'` | |
if [[ `mount -p | grep $MYDIR2 | grep -c zfs` > 0 ]] | |
then | |
#echo "DEBUG: this is zfs" | |
USED=$((`zfs get -o value -Hp used $PWD` / 1024)) > /dev/null | |
AVAIL=$((`zfs get -o value -Hp available $PWD` / 1024)) > /dev/null | |
TOTAL=$(($USED+$AVAIL)) > /dev/null | |
echo $TOTAL $AVAIL | |
else | |
#echo "DEBUG: this is not zfs " | |
df $PWD | tail -1 | awk '{print $2" "$4}' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment