Skip to content

Instantly share code, notes, and snippets.

@pgtwitter
Last active September 21, 2015 15:19
Show Gist options
  • Save pgtwitter/708ffea6010ee98f0d50 to your computer and use it in GitHub Desktop.
Save pgtwitter/708ffea6010ee98f0d50 to your computer and use it in GitHub Desktop.
Used Volume Size Ratio of NASNE (on Mac OS X / マウント済みのケース)
#!/bin/bash
NAME=`smbutil statshares -a | awk 'BEGIN{F=0}/^nasne_home/{F=1}F==1 && /SERVER_NAME/ {print $2;exit}'`
IPADDR=`smbutil lookup ${NAME} | awk '/^IP address of /{print $NF}'`
URL="http://${IPADDR}:64210/status/HDDInfoGet?id=0"
curl -s ${URL} \
| awk '{gsub("[,}]", "\n");print $0}' \
| awk '/usedVolumeSize/{u=$NF}/totalVolumeSize/{t=$NF}END{printf "%.2f%%\n", u/t*100}'
@pgtwitter
Copy link
Author

NAMEがわかってたら2行目は直接代入すれば,マウントしてなくても使用できる(?)(NAME="nasne-000000").

nasne HOME: ver 2.51
参考: "【nasne】APIを調べてみた。ディスク容量が知りたい、他" http://pocketstudio.jp/log3/2014/12/07/nasune_api/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment