Traffic accounting
Got this from here:
http://www.catonmat.net/blog/traffic-accounting-with-iptables/
All i'm interested in is my monthly bandwidth consumption, not the individual devices, there are plenty of forum threads/tools to do that. But why bring in additional tools when iptables has it all?
iptables -N TRAFFIC_ACCT
iptables -I FORWARD -j TRAFFIC_ACCT
iptables -A TRAFFIC_ACCT
http://www.catonmat.net/blog/traffic-accounting-with-iptables/
All i'm interested in is my monthly bandwidth consumption, not the individual devices, there are plenty of forum threads/tools to do that. But why bring in additional tools when iptables has it all?
iptables -N TRAFFIC_ACCT
iptables -I FORWARD -j TRAFFIC_ACCT
iptables -A TRAFFIC_ACCT
and to just get the number:
iptables -L TRAFFIC_ACCT -v | sed -n 3p | cut -d' ' -f2
to reset the counters
/usr/sbin/iptables -L TRAFFIC_ACCT -Z
the cron job to reset at the begining of the month, and a daily telegram msg
1 0 1 * * /usr/sbin/iptables -L TRAFFIC_ACCT -Z
0 8 * * * /usr/bin/curl -s -X POST https://api.telegram.org/<BOTID>/sendMessage -d chat_id=<CHATID> -d text="$(/usr/sbin/iptables -L TRAFFIC_ACCT -v | /bin/sed -n 3p | /usr/bin/cut -d' ' -f3)" >/dev/null 2>&1
to reset the counters
/usr/sbin/iptables -L TRAFFIC_ACCT -Z
the cron job to reset at the begining of the month, and a daily telegram msg
1 0 1 * * /usr/sbin/iptables -L TRAFFIC_ACCT -Z
0 8 * * * /usr/bin/curl -s -X POST https://api.telegram.org/<BOTID>/sendMessage -d chat_id=<CHATID> -d text="$(/usr/sbin/iptables -L TRAFFIC_ACCT -v | /bin/sed -n 3p | /usr/bin/cut -d' ' -f3)" >/dev/null 2>&1
(you'll need to opkg install ca-bundle for the https to work)
Hi
ReplyDeleteGreat Post!!
We’ve answered all the general and tech queries of Zyxel router users. So, if you’ve any, reach out to us on our website. In addition, we provide guides for all the configuration, setup, and Zyxel Login. So please don’t be hesitant to reach us. Adding more to this, if there is an issue with your router, you can also follow our guides to fix that issue.
Zyxel Router
Zyxel Router Login
Zyxel Login
Zyxel Router Setup