Network throughput

Коньков Евгений kes-kes at
Wed Jan 11 18:00:36 UTC 2012

Здравствуйте, Mike.

Вы писали 11 января 2012 г., 13:24:00:

MW> Hi guys, Been a while since i've had need to post to the list :)

MW> I'm trying to gather network throughput information on a box of ours  
MW> and I'm having a little problem, the throughput is to be measured on a
MW> per-minute basis and i've been trying to use netstat for this (count  
MW> now - count before/timeperiod) however netstats byte counter resets  
MW> far too quickly to be usefull (this is a busy gb link), i've had a  
MW> look at vnstat but this only seems to operation on an hour or higher  
MW> and I need to get down to the minute, does anyone have any suggestions
MW> of a tool better suited to this ?

snmp will help


use warnings;
use strict;

my $snmpauth= $ARGV[0];    #auth string like '-v 1 passhere', supplied asis to snmpget
my $host= $ARGV[1];        #
my $ifIndex= $ARGV[2];     #interface name or index

if( !$ifIndex ) {
  print `/usr/local/bin/snmpwalk $snmpauth $host .`;
  exit 0;

#print `/usr/local/bin/snmpwalk $snmpauth $host IF-MIB::ifName`;
if( $ifIndex =~ /^[a-zA-Z]/ ) {
  #print "/usr/local/bin/snmpwalk $snmpauth $host IF-MIB::ifName";
  `/usr/local/bin/snmpwalk $snmpauth $host IF-MIB::ifName` =~ /\.(\d+).+$ifIndex/;
  $ifIndex= $1;

my $octetsIn=   `/usr/local/bin/snmpget $snmpauth -O qv $host .$ifIndex`;  chop $octetsIn;  #IF-MIB::ifHCInOctets
my $octetsOut=  `/usr/local/bin/snmpget $snmpauth -O qv $host .$ifIndex`; chop $octetsOut; #IF-MIB::ifHCOutOctets
my $packetsIn=  `/usr/local/bin/snmpget $snmpauth -O qv $host .$ifIndex`;    chop $packetsIn; #IF-MIB::ifInUcastPkts
my $packetsOut= `/usr/local/bin/snmpget $snmpauth -O qv $host .$ifIndex`;    chop $packetsOut;#IF-MIB::ifOutUcastPkts

print "octetsIn:$octetsIn octetsOut:$octetsOut packetsIn:$packetsIn packetsOut:$packetsOut\n";

С уважением,
 Коньков                          mailto:kes-kes at

More information about the freebsd-questions mailing list