set -e
function rm_temp () {
- if [[ ${TEMP} ]]; then
- rm ${TEMP}
- unset TEMP
+ if [[ ${TMP} ]]; then
+ rm ${TMP}
+ unset TMP
fi
}
# If you think what follows is fugly, please have a
# look at the DNS323's web app HTML
- TEMP=$(mktemp /tmp/status.XXXXXX)
+ TMP=$(mktemp /tmp/status.XXXXXX)
curl -s \
-L http://${DNS323_HOSTNAME}/goform/adv_status \
- -d "" > ${TEMP}
+ -d "" > ${TMP}
- cat ${TEMP} | \
+ cat ${TMP} | \
html2text | \
grep "\(Sync Time Remaining\|Volume Name\|Volume Type\|Total Hard Drive Capacity\|Used Space\|Unused Space\)": | \
- sed -e "s/^[ \t]*//"
-
- grep "var temper" ${TEMP} | sed -e "s/^.*\"\([0-9]*\):\([0-9]*\)\".*$/Temperature: \1F \/ \2C/"
+ sed -e "s/^[ \t]*//" | while read line; do
+ label=$(echo ${line} | sed -e "s/:.*$//")
+ value=$(echo ${line} | sed -e "s/^[^0-9]*\([0-9]*\).*$/\1/")
+ comment=""
+ case ${label} in
+ "Total Hard Drive Capacity")
+ total=${value}
+ ;;
+ "Used Space")
+ comment="($(((value*100)/total))%)"
+ ;;
+ "Unused Space")
+ comment="($(((value*100)/total))%)"
+ ;;
+ *)
+ ;;
+ esac
+ echo "${line} ${comment}"
+ done
+
+ grep "var temper" ${TMP} | sed -e "s/^.*\"\([0-9]*\):\([0-9]*\)\".*$/Temperature: \1F \/ \2C/"
rm_temp