Skip to content

Instantly share code, notes, and snippets.

@smallfield
Last active August 29, 2015 14:08
Show Gist options
  • Save smallfield/9a0237be7f9ad67fabb9 to your computer and use it in GitHub Desktop.
Save smallfield/9a0237be7f9ad67fabb9 to your computer and use it in GitHub Desktop.
IIJmioのデータ通信残量を表示するMuninプラグイン
#!/bin/sh
# SETTING HERE
mio_id=hoge
mio_pass=fuga
if [ $1 = "config" ]
then
cat <<'EOM'
graph_title IIJmio
graph_vlabel Capacity
capacity.label Capacity
capacity.draw AREASTACK
graph_args --rigid --lower-limit 0
EOM
exit 0
fi
base_url=https://www.iijmio.jp
# initialize
cookie_file=/tmp/cookie.txt
cat /dev/null > ${cookie_file}
alias mywget='wget -vv -S -O - --save-cookies=${cookie_file} --load-cookies=${cookie_file} --keep-session-cookies --user-agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)"'
# get cookie
mywget ${base_url}/auth/login.jsp > /dev/null 2> /dev/null
# login
mywget --post-data "type=id&j_uri=%2Fauth%2Fmessage%2Fwelcome.jsp&j_username=${mio_id}&j_password=${mio_pass}&login.x=19&login.y=6" ${base_url}/j_security_check > /dev/null 2> /dev/null
# get data
echo capacity.value `mywget ${base_url}/service/setup/hdd/couponstatus/ 2> /dev/null | grep MB$ | head -1 | sed 's/\t//g' | sed 's/MB//g'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment