Skip to content

Instantly share code, notes, and snippets.

@toshi0383
Last active August 29, 2015 14:11
Show Gist options
  • Save toshi0383/e319ebc5919721617c4c to your computer and use it in GitHub Desktop.
Save toshi0383/e319ebc5919721617c4c to your computer and use it in GitHub Desktop.
GL-06P の累計受信データ量を取得するシェル
#!/bin/bash
URL="http://pocketwifi.home/api/monitoring/traffic-statistics"
response=`curl -s $URL`
PATTERN=TotalDownload
downloadByte=`echo "$response" \
| grep $PATTERN \
| sed -e "s/<TotalDownload>//g" -e "s~</TotalDownload>~~g"`
if [ ! $downloadByte ];then
exit 1;
fi
downloadGigaByte=`expr $downloadByte / 1024 / 1024 / 1024` #切り捨て御免
echo "["`date "+%Y/%m/%d %H:%M:%S"`"]:" $downloadGigaByte "GB"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment