1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Script for Per-IP bandwidth monitoring

Discussion in 'Tomato Firmware' started by leechange, Nov 28, 2008.

  1. leechange

    leechange LI Guru Member

    #!/bin/sh
    iptables -N acc-in
    iptables -N acc-out
    for IP in `cat /proc/net/arp | grep br0 | awk '{printf $1"\t"}'`; do
    iptables -A acc-in -d $IP -j RETURN
    iptables -A acc-out -s $IP -j RETURN
    done
    iptables -I FORWARD -o br0 -i ! br0 -j acc-in
    iptables -I FORWARD -i br0 -o ! br0 -j acc-out

    sleep 1

    echo Donwload
    iptables -L acc-in -v | grep 0 | awk '{printf $9"\t"$2" Bytes/s\n"}'
    echo
    echo Upload
    iptables -L acc-out -v | grep 0 | awk '{printf $8"\t"$2" Bytes/s\n"}'

    iptables -D FORWARD -i br0 -o ! br0 -j acc-out
    iptables -F acc-out
    iptables -X acc-out
    iptables -D FORWARD -o br0 -i ! br0 -j acc-in
    iptables -F acc-in
    iptables -X acc-in

    Because of the period of command executing, the result is greater than actual.
     

    Attached Files:

    • flux.zip
      File size:
      366 bytes
      Views:
      22
  2. powersquad

    powersquad Addicted to LI Member

    where does it reports the results?
     

Share This Page