Forum Discussion
mikand_61525
Nov 23, 2008Nimbostratus
View current bandwidth for particular interface
Is it possible (with some built in command or such) to through ssh see how much bandwidth (in mbit/s or so) a F5 BigIp unit utilizes over a particular interface?
ifconfig can be used to...
JRahm
Dec 04, 2008Admin
You can check the status from any OS with Perl, just make sure the Net::SNMP module is installed. The interface map is from a 6400, if you have other interface names, you'll need to append them to the map. The end of the oids are ascii representations of the interface characters, and are preceded by the number of characters, so 1.1 in ascii is 3.49.46.49, and 1.10 is 4.49.46.49.48, etc.
[code]
!/usr/bin/perl -w
use strict;
use Net::SNMP qw(:snmp);
my $usage = "ltm_intStat.pl ";
die "Usage: $usage\n" if $ARGV != 3;
my $host = $ARGV[0];
my $snmp_comm = $ARGV[1];
my $int = $ARGV[2];
my $interval = $ARGV[3];
chomp ($host , $snmp_comm , $int , $interval);
my $ltm_InBytes_Index = "1.3.6.1.4.1.3375.2.1.2.4.4.3.1.3";
my $ltm_OutBytes_Index = "1.3.6.1.4.1.3375.2.1.2.4.4.3.1.5";
my %int_map = ("1.1"=>".3.49.46.49",
"1.2"=>".3.49.46.50",
"1.3"=>".3.49.46.51",
"1.4"=>".3.49.46.52",
"1.5"=>".3.49.46.53",
"1.6"=>".3.49.46.54",
"1.7"=>".3.49.46.55",
"1.8"=>".3.49.46.56",
"1.9"=>".3.49.46.57",
"1.10"=>".4.49.46.49.48",
"1.11"=>".4.49.46.49.49",
"1.12"=>".4.49.46.49.50",
"1.13"=>".4.49.46.49.51",
"1.14"=>".4.49.46.49.52",
"1.15"=>".4.49.46.49.53",
"1.16"=>".4.49.46.49.54",
"2.1"=>".3.50.46.49",
"2.2"=>".3.50.46.50",
"2.3"=>".3.50.46.51",
"2.4"=>".3.50.46.52",
"mgmt"=>".4.109.103.109.116");
my $ltm_intBytesIn = $ltm_InBytes_Index . $int_map{$int};
my $ltm_intBytesOut = $ltm_OutBytes_Index . $int_map{$int};
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $snmp_comm,
-port => 161,
-version => 'snmpv2c',
-nonblocking => 0
);
if (!defined $session)
{
print "Received no SNMP response from $host\n";
print STDERR "Error: $error\n";
exit -1;
}
Get first instance
my $oids_1 = $session->get_request(
-varbindlist =>
[$ltm_intBytesIn, $ltm_intBytesOut] );
sleep $interval;
Get second instance
my $oids_2 = $session->get_request(
-varbindlist =>
[$ltm_intBytesIn, $ltm_intBytesOut] );
Calculate Rates
my $rate_in = ($oids_2->{$ltm_intBytesIn} - $oids_1->{$ltm_intBytesIn})*8 / $interval;
my $rate_out = ($oids_2->{$ltm_intBytesOut} - $oids_1->{$ltm_intBytesOut})*8 / $interval;
Round to integer
$rate_in = int($rate_in + .5);
$rate_out = int ($rate_out + .5);
my $rate_total = $rate_in + $rate_out;
Print Results
print "\n\n\t$rate_in bits/second (IN)\n";
print "\t$rate_out bits/second (OUT)\n";
print "\t$rate_total bits/second (TOTAL)\n";
[/code]
I ran this successfully with ActiveState perl on my XP machine:
[blockquote]
C:\dev\perlscripts>ltm_intStat.pl my.bigip.domain.com public mgmt 5
1429 bits/second (IN)
205 bits/second (OUT)
1634 bits/second (TOTAL)
[/blockquote]
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects