Results 1 to 9 of 9

Thread: Traffic count

  1. #1
    Join Date
    Jan 2009
    Location
    European Union
    Posts
    48

    Default Traffic count

    Hi,

    I'm looking for a way to count monthly traffic. I guess it's not the most difficult thing to do, but I don't get any forward at the moment (well, my skills are also limited...). I tried netacct but the logfile confused me too much, Knemo claims it'd count also the monthly traffic but mine turned out to be senile (and crashes)...

    My computer is conected over a router to the internet and what interests me is just my traffic. To get the data from the router is not possible. Most solutions I found were dealing with servers or routers.

    If it matters I'm using KDE 4.1 (openSUSE 11.1), but the program doesn't have to be colourful . A nice CLI program would do. Even if it just can display the traffic per session. But the output should be in a nice format.

    Help is greatly appreciated.

  2. #2
    Join Date
    Jan 2009
    Location
    PARADISE
    Posts
    929

    Default Re: Traffic count

    Hi there and welcome to the forums! Please consider taking a read in these threads:

    - Bandwith Meter Required - openSUSE Forums
    - Good bandwidth monitor software for gnome? - openSUSE Forums
    - Network Traffic Management Tools - openSUSE Forums

    Please let us know if you need further instructions once you've selected one that suits your needs (just test them all). I'll gladly help, too.
    CHECK OUT THESE GitHub PROJECTS!

    https://secupwn.github.io/Android-IMSI-Catcher-Detector/
    https://github.com/SecUpwN/Spotify-AdKiller

  3. #3
    Join Date
    Jan 2009
    Location
    European Union
    Posts
    48

    Default Re: Traffic count

    Thank you, I found a tool which I like: iptraf. :-)

    I wrote a very basic script to sum up all traffic (up and down together) which is enough for my needs. What's left is to make it run on start-up.

    The only thing which worries me a bit is to run something self-scripted as root... What could I do to prevent it causing harm? w-permisson just for root and maybe use AppAmor to protect it?

    It evaluates (well, sums using awk) the informations since the last boot, could this slow the boot process down significantly? (The computer doesn't run days, so the log-file is somewhat limited).

  4. #4
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    32,355
    Blog Entries
    15

    Default Re: Traffic count

    Quote Originally Posted by KarlaKa
    Thank you, I found a tool which I like: iptraf. :-)

    I wrote a very basic script to sum up all traffic (up and down
    together) which is enough for my needs. What's left is to make it run on
    start-up.

    The only thing which worries me a bit is to run something self-scripted
    as root... What could I do to prevent it causing harm? w-permisson just
    for root and maybe use AppAmor to protect it?

    It evaluates (well, sums using awk) the informations since the last
    boot, could this slow the boot process down significantly? (The computer
    doesn't run days, so the log-file is somewhat limited).
    Hi
    Your probably better off to use snmp to get the in and out octets of
    the interface. Is this to keep track of bandwith usage? If so then you
    need to look at the router and if it has snmp capabilities to get the
    information.

    --
    Cheers Malcolm (Linux Counter #276890)
    SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.25-0.1-default
    up 1 day 18:35, 3 users, load average: 0.04, 0.16, 0.08
    GPU GeForce 8600 GTS Silent - Driver Version: 185.18.14


  5. #5
    Join Date
    Jan 2009
    Location
    European Union
    Posts
    48

    Default Re: Traffic count

    Hi,

    thank you for the idea. Well, all I need is to keep some kind of track how much traffic I used (no need to be in real-time) as soon I'll have a monthly limit (no need for 100% exact data) and I'll connect to the internet via (um, no clue how one calls that..) well, some network in which I'm just a small user without any kind of special rights. So I guess one can't use snmp? Besides I just understood the iptraf output .

    Or I could try to use a cronjob every hour (and before shut-down) to evaluate the data. But it'll take a while to figure it out... (I wrote my first bash-script just one week ago )

    Here is my script btw, the only problem could be a slowdown if the log is very long, what do you think?

    Code:
    #!/bin/bash
    
    
    # this script collects traffic in bytes with iptraf and 
    # writes the sums to a file
    
    Log=/var/log/iptraf
    TrafCol=/tmp/TrafCalc.col
    TrafTot=/tmp/TrafCalc.tot
    TrafSum=/var/log/TrafSum
    
    text="Datum \t\t\t\tTraffic \tTotal"
    
    # read log + parse traffic in bytes + sum it up
    cat $Log | cut '-d;' -f4 | cut '-d ' -f2 > $TrafCol
    summe=$(awk '{sum += $1} END {print sum}' $TrafCol)
    rm $Log
    
    # create TrafSum if not already existing
    if [ ! -e $TrafSum ]
    then 
    echo -e $text > $TrafSum 
    fi
    
    # caluclate total traffic in MByte
    cat $TrafSum | cut '-d ' -f8 > $TrafTot
    summe_total=$[$summe+$(awk '{sum += $1} END {print sum}' $TrafTot)]
    rm $TrafCol
    rm $TrafTot
    summe_total=$[$summe_total/1024] #in MByte
    
    # output in TrafSum
    echo -e "$(date)  $summe \t\t $summe_total MByte" >> $TrafSum 
    
    # start iptraf
    iptraf -i br0 -L $Log -B

  6. #6
    Join Date
    Jul 2008
    Location
    Voorhout, Netherlands
    Posts
    262

    Default Re: Traffic count

    KarlaKa wrote:
    > Hi,
    >
    > I'm looking for a way to count monthly traffic. I guess it's not the
    > most difficult thing to do, but I don't get any forward at the moment
    > (well, my skills are also limited...). I tried netacct but the logfile
    > confused me too much, Knemo claims it'd count also the monthly traffic
    > but mine turned out to be senile (and crashes)...
    >
    > My computer is conected over a router to the internet and what
    > interests me is just my traffic. To get the data from the router is not
    > possible. Most solutions I found were dealing with servers or routers.
    >
    > If it matters I'm using KDE 4.1 (openSUSE 11.1), but the program
    > doesn't have to be colourful . A nice CLI program would do. Even if
    > it just can display the traffic per session. But the output should be in
    > a nice format.
    >
    > Help is greatly appreciated.


    Have a look at vnstat.
    http://humdi.net/vnstat/

    Has a CLI and a CGI for pretty pictures.


    Theo

  7. #7
    Join Date
    Jan 2009
    Location
    European Union
    Posts
    48

    Default Re: Traffic count

    Quote Originally Posted by LittleRedRooster View Post

    Have a look at vnstat.
    vnStat - a network traffic monitor for Linux and BSD

    Has a CLI and a CGI for pretty pictures.

    Theo
    This one looks great! Seems to be what I was looking for. Thank you!

  8. #8
    HarryRoberts NNTP User

    Thumbs up Re: Traffic count

    im new here. Also looking for traffic counter ,vnstat seems to be the best solution so far .

    Thanks !

  9. #9
    Join Date
    Jan 2009
    Location
    PARADISE
    Posts
    929

    Default Re: Traffic count

    Guys, would be great to get some help on this: Currentyl I want to test rrdtool, which SHOULD draw graphs like the following:



    Mh... I see your huge eyes, guys. Vnstat is nothing compared to this visualization. How to configfure rrdtool to easily access the graphics for NETWORK TRAFFIC in real time?
    Actually I want rrdtool to continously show me upload/download traffics without eating HDD space.
    CHECK OUT THESE GitHub PROJECTS!

    https://secupwn.github.io/Android-IMSI-Catcher-Detector/
    https://github.com/SecUpwN/Spotify-AdKiller

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •