Assuming your Sitecom is on http://192.168.0.1/ , make sure you can log in on the Sitecom router with your favorite webbrowser: username is 'admin', password is on a sticker on the bottom of your Sitecom at "WPA2 password". In the examples below I use the password '8BT5J5Y6AAAA'
If that works, first test that a plain curl login works:
curl --user admin:8BT5J5Y6AAAA 'http://192.168.0.1/index.htm'
That should give some HTML garbage, but not "401 Unauthorized". If you get "401 Unauthorized" recheck your password.
If it works, you can proceed:
Get your public IPv4 address:
$ curl --silent --user admin:8BT5J5Y6AAAA 'http://192.168.0.1/stanet.htm' | grep -i sta_ip:
var st2={sta_ip:"83.128.180.11",sta_mac:"64:D1:A3:07:20:AA",sta_mask:"255.255.252.0",sta_dns1:"62.45.45.45,62.45.46.46",sta_gw:"83.128.180.1"};
So my public IPv4 address is 83.128.180.11
Get an overview of the traffic (alas in packets, not in bytes):
$ curl --silent --user admin:8BT5J5YAAAA 'http://192.168.0.1/stats.htm' | grep -i wRxNum:
var st={wlDev:"1",wlTxNum:" 15406",wlRxNum:" 30387",lTxNum:" 1031",lRxNum:" 562",wTxNum:" 4133",wRxNum:" 7482"};
You need to parse that output to get what you want. Here's the Sent Packets and Receive Packets (so: not bytes) on your Ethernet WAN interface you could feed into MRTG:
$ curl --silent --user admin:8BT5J5Y6AAAA 'http://192.168.0.1/stats.htm' | grep -i wRxNum: | awk -F "[^0-9]*" '{ print $(NF-2) "\n" $(NF-1) "\n\n" }'
13689485
38296365
Looks good. Warning: these are packets ...not bytes. Multiply with the typical packet size in Send resp Received direction (so 50 resp 1200?) to get bytes. Example:
$ curl --silent --user admin:8BT5J5Y6AAAA 'http://192.168.0.1/stats.htm' | grep -i wRxNum: | awk -F "[^0-9]*" '{ print 90*$(NF-2) "\n" 1200*$(NF-1) "\n\n" }'
1253322450
46662481200
Note: you have to change (NF-2) and (NF-1) to get the right Up and Down
$ curl --silent --user admin:8BT5J5Y6AAAA 'http://192.168.0.1/stats.htm' | grep -i wRxNum: | awk -F "[^0-9]*" '{ print $(NF-2) "\n" $(NF-1) "\n\n" }'
13689485
38296365
Looks good. Warning: these are packets ...not bytes. Multiply with the typical packet size in Send resp Received direction (so 50 resp 1200?) to get bytes. Example:
$ curl --silent --user admin:8BT5J5Y6AAAA 'http://192.168.0.1/stats.htm' | grep -i wRxNum: | awk -F "[^0-9]*" '{ print 90*$(NF-2) "\n" 1200*$(NF-1) "\n\n" }'
1253322450
46662481200
Note: you have to change (NF-2) and (NF-1) to get the right Up and Down
As this is an IPv6 blog, here is some IPv6 stuff:
$ curl --silent --user admin:8BT5J5Y6AAA 'http://192.168.0.1/ipv6_stainfo.htm' | grep -i fe80
var ipv6_wan_linklocal = 'fe80::66d1:a3ff:fe07:aaaa/64';
var ipv6_linklocal = 'fe80::66d1:a3ff:fe07:aaaa/64';
Happy curling!
(Met dank aan Rob voor de Sitecom)
No comments:
Post a Comment