ifconfig - in out

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
banaan
Posts: 6
Joined: Thu Nov 21, 2002 3:29 pm

ifconfig - in out

Post by banaan »

Hi,

Iam looking for a script that gives me the in/out from my eth0 NIC, is there such a script?
I can`t find it..

Thanks,

banaan
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

It looks like this post may contain the script you are requesting:

http://www.raxnet.net/board/viewtopic.php?p=1784#1784

-Ian
Guest

Post by Guest »

Here's one I wrote earlier today:

Code: Select all

#!/usr/bin/perl

  open(IN,"/proc/net/dev");
  while(<IN>) {
    chomp;
    #if ((index($_,"Int")<0) && (index($_,"byte")<0)) {
    if ( /:/ ) {
      ($combined, $a, $d, $d, $d, $d, $d, $d, $output, $e)=split;
      ($name, $input)=split(":",$combined);
      if(!$input) { ($input, $output) = ($a, $e); }
      $devin{$name}=$input;
      $devout{$name}=$output;
#      $sampletime{$name}=time;
      }
    }
  close(IN);

# The format is in <Receive/In Bytes> <Transmit/Out Bytes>
# You can do more than one interfaces at a time, like:
# bandwidth.pl eth0 lo
# and it will return eth0-in eth0-out lo-in lo-out

if (@ARGV) {
        foreach $argv (@ARGV) {
                push(@output,"$devin{lc($argv)} $devout{lc($argv)}");
        }
        print "@output";
}
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests