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

Per User statistics&SNMP - my solution - SOLVED!

Discussion in 'Tomato Firmware' started by Syster, Mar 18, 2007.

  1. Syster

    Syster LI Guru Member

    Hi all! ;)
    I've found on openwrt forum script wich gives us per user bandwidth statistics ;)
    I've modified it to get working on Tomato. Here you go :)

    iptables -N traffic_in
    iptables -N traffic_out
    iptables -I FORWARD 1 -j traffic_in
    iptables -I FORWARD 2 -j traffic_in
    iptables -A traffic_in -d <IP of computer 1 added to statistics>
    iptables -A traffic_out -s <IP of computer 1 added to statistics>
    iptables -A traffic_in -d <IP of computer 2 added to statistics>
    iptables -A traffic_out -s <IP of computer 2 added to statistics>
    ...
    iptables -A traffic_in -d <IP of computer X added to statistics>
    iptables -A traffic_out -s <IP of computer X added to statistics>

    After typing it, we can check statistics by typing:
    iptables -L traffic_in -vn <-For Download
    iptables -L traffic_out -vn <-For Upload

    ;) Worked for me ;)

    Also i've found how to solve problem with hanging SNMP daemon on tomato.
    The problem was because normally on tomato there's no libpthread library. After compiling FW with this library included, problems with SNMP has gone :)

    ENOY! :)

    PS: I've wroted an email to Jon few days ago about these statistics, maybe he'll be interested in it. I hope he answer to me...
     
  2. bogderpirat

    bogderpirat Network Guru Member

    this is quite interesting. thanks!

    about the snmp daemon: you're refering to the hangups while doing an snmpwalk, right? the one mentioned by bokh in the tutorial thread? if so, would you care to share your binary with us? i'd be quite thankful!
     
  3. Syster

    Syster LI Guru Member

    Well, now i can't :D
    Because if you want to use libpthread.so library you have to place it in /lib directory, wich is read-only, even it isn't possible to make links to inside /lib folder...
    The only one way to get libpthread inside /lib is recompiling tomato with libpthreads enabled.
    I enabled it in my version of tomato. In my version of tomato I've added little stuff, and one of it is translated WebGUI into polish language, which i think, you don't like :p

    But I'll make a special version with English web gui tonight ;)
     
  4. bogderpirat

    bogderpirat Network Guru Member

    alright, i see. the binary isn't too important to me, i've never done a snmpwalk anyways. it'd just be nice to get a fully working version, if you catch my drift.

    now concerning that script, i've got a couple of questions:
    1. the download amount appears to show roughly twice the actual amount. after a download of a 5mb file, traffic_in says about 11M for my ip. is that normal?
    2. traffic_out says nothing, 0 for every ip.

    this is what i'm using:
    got any idea? thanks in advance!
     
  5. Syster

    Syster LI Guru Member

    Oh, man, i,'ve just make a mistake:
    iptables -N traffic_in
    iptables -N traffic_out
    iptables -I FORWARD 1 -j traffic_in
    iptables -I FORWARD 2 -j traffic_out
    iptables -A traffic_in -d 192.168.0.2
    iptables -A traffic_out -s 192.168.0.2
    iptables -A traffic_in -d 192.168.0.3
    iptables -A traffic_out -s 192.168.0.3
    iptables -A traffic_in -d 192.168.0.4
    iptables -A traffic_out -s 192.168.0.4

    second iptables -I FORWARD 2 -j traffic_out should forward into traffic_out table, not traffic_in
     
  6. bogderpirat

    bogderpirat Network Guru Member

    i didn't see it either. again: thanks a lot!
     
  7. Syster

    Syster LI Guru Member

    No no...you have to type it after reboot, because old script's working....

    Code:
    iptables -N traffic_in
    iptables -N traffic_out
    iptables -A traffic_in -d 192.168.0.2
    iptables -A traffic_out -s 192.168.0.2
    iptables -A traffic_in -d 192.168.0.3
    iptables -A traffic_out -s 192.168.0.3
    iptables -A traffic_in -d 192.168.0.4
    iptables -A traffic_out -s 192.168.0.4
    iptables -I FORWARD 1 -j traffic_in
    iptables -I FORWARD 2 -j traffic_out
    
     
  8. bogderpirat

    bogderpirat Network Guru Member

    so putting it in the firewall script won't do it?

    do the iptables-chains remain active after the wan interface restarts?
     
  9. schoergei

    schoergei Addicted to LI Member

    I know this thread is very old, but are there any chances, to save the statistics to a CIFS automaticly? Or every hour? Or even a shiny option in the web interface of tomato?
     
  10. srouquette

    srouquette Network Guru Member

    +1 for the web interface :)
     
  11. QSxx

    QSxx LI Guru Member

    +2 over here!
     
  12. schoergei

    schoergei Addicted to LI Member

  13. SenorLoco

    SenorLoco Guest

    I've been using this for awhile now and it works great on my 520gu running Tomato Firmware v1.25.8634 ND USB Std (teddy_bear). When I tried upgrading to v1.25.87.35 it stopped working. I did notice the iptables version went from 1.3.7 to 1.3.8 when I upgraded so I imagine that is what broke it. I submitted a bug report on the authors launchpad site but so far it hasn't seen any activity.
     
  14. schoergei

    schoergei Addicted to LI Member

    Only the "in" Bandwith will be displayed in the console with my Tomato, the out Bandwith is not working.
     
  15. TexasFlood

    TexasFlood Network Guru Member

    I just set this up, currently on Thor v1.25.8515 RAF ND USB MOD .8. A bit tricky to get it all set up right but it's working now monitoring bandwidth on the IPs I want it to, GUI working also. The automatic detection of static IPs worked but I have some IPs in there that aren't currently in use but I don't want to delete them nor do I want to see them in the report so went with the manual method. Pretty cool.
     
  16. schoergei

    schoergei Addicted to LI Member

    How did you make it?
     

Share This Page