Find the answer to your Linux question:
Results 1 to 9 of 9
aloha got question: typing /sbin/ifconfig eth0 gets me info about the nic device eth0, among other stuff it is received packets (RX), and sent packets (TX) - cumulative since the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2004
    Location
    macedonia
    Posts
    7

    NIC logging - RX & TX counters


    aloha

    got question: typing /sbin/ifconfig eth0 gets me info about the nic device eth0, among other stuff it is received packets (RX), and sent packets (TX) - cumulative since the last initialization of eth0. also, there is field that tells me the received number of bytes - RX, sent number of bytes TX,also cumulative. my question is where can i see some more info especially eventual log files covering these statistics. i suppose it is somewhere written ha? i wasnt able to find, i need to do some diagnostics so i need this thing, tried googling but had no luck....

    please advise

    smiles

    Darko

  2. #2
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    AFAIK, you can't get more detailed stats by default. There is probably a program/daemon that would do it. Try googling for ethernet stat monitor or something...I'll see what I can find later if you/someone else doesn't find a solution...off to work now.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  3. #3
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Well, it isn't logged or anything by default, but it would be the easiest thing in the world to make a Perl script that does that:
    Code:
    #!/usr/bin/perl
    open IFC, "ifconfig eth0 |";
    while&#40;<IFC>&#41; &#123;
        if&#40;&#40;$rb, $wb&#41; = /RX bytes&#58;\s*&#40;\d*&#41;.*TX bytes&#58;\s*&#40;\d*&#41;/&#41; &#123;
            last;
        &#125;
    &#125;
    close IFC;
    open LOG, ">>/tmp/logfile";
    print LOG "$rb $wb\n";
    close LOG;
    Then just chmod that to 755 and put it in your /etc/cron.daily or similar, and you'll get one line per day in /tmp/logfile telling you the number of read and written bytes. That's the power of Perl for you. =)

  4. #4
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    And don't forget to run it when before you reboot/restart your ethernet controller.

    BTW...I would've gotten to that...just was rushed for work this morning.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  5. #5
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Seriously, Perl has to be the best utility language ever designed...

  6. #6
    Just Joined!
    Join Date
    Jun 2004
    Location
    macedonia
    Posts
    7
    so thats it ha? no detailed information or eventual log...
    its just not clear to me about that perl script - how do i set up to run before initializing the network interface?

  7. #7
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    If you copy it into /etc/cron.daily, cron will automatically run it once every hour (on most somewhat standard distros, at least). I'm not sure about your intention... was that what you wanted to know?

    I'm not sure exactly what kind of "detailed information" you're referring to. Is there anything more you wish to know about your networking traffic?

  8. #8
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    If you want to run it before interface init, you can edit your rc script (assuming that you use one) that handles the initialization. But you don't want to run it before you initialize the interface...just before you RE-initialize it or restart it or shut it down. It can be accomplished the same way, just putting the call at a different point in the rc script.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  9. #9
    Just Joined!
    Join Date
    Jun 2004
    Location
    macedonia
    Posts
    7
    thanks!

    by detailed i meant the same my initial question...where does the interface memorize the traffic sums for RX and TX while enabled/up

Posting Permissions

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