If you are in the situation of having a Netgear product that runs the TeamF1 firmware like a FVS318/FVS318G or FVS338/FVS338G (and cannot switch to something better) you probably want to use the “Traffic Meter” that does traffic accounting for your broadband connection…
But there is a major drawback: the Traffic Meter loses your statistics on each power cycle :(
While this script can not fully overcome these limitations, it makes dealing with them easier. It queries the traffic statistics using the telnet CLI in an easily machine-parsable format (
cut are your friends here) using an
expect script which is suited for automating highly interactive commands (like telnet).
#!/usr/bin/expectset timeout 20set name [lindex $argv 0]set user [lindex $argv 1]set password [lindex $argv 2]spawn telnet $nameexpect "login: "send "$user\n"expect "Password: "send "$password\n"expect "$ "send "monitor/trafficMtr/summary wanId 1\n" # use first WAN interfaceexpect "Percentage of this Month's Limit"expect "$ "send "exit\n"expect eof
The first part does parsing the scripts parameters and specifying the executable to launch, the second part then does the communication with your router using the send (sends some characters) and expect (waits until the given characters are received) statements. For the script to function you may need to install the
expect package on your system.
Use it like this:
./trafficMtr.sh <host> <username> <password>
Now you can use the output anyway you like, grepping it, storing it, etc. in order to persist the traffic statistics using a cron job so that even in case of a power cycle that information is not lost.
is licensed under Creative Commons BY-NC-SA 3.0.