Forum Discussion

mikand_61525's avatar
mikand_61525
Icon for Nimbostratus rankNimbostratus
Nov 23, 2008

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 see number of packets and tcpdump can be used to capture the actual traffic but I want for debugging purposes see how many mbit/s there are for a particular interface.
  • Maybe you could get this via SNMP? I'm not too sure on that. 'b interface' and 'b vlan' will give you cumulative packets and bits in/out, but not current throughput.

     

     

    Aaron
  • Hmm perhaps I could use "b interface" and "b vlan" in order to create a script that will count the diff in numbers of bytes passing through each second and this way get sort of a bandwidth meter (basically its for debugging purposes to see approx how many mbit/s there is on a particular interface). But it would be cooler if such thing already existed :)
  • Hamish's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus
    Can you get access to a copy of Cacti? Or if no existing one, do you have a box (Or even a VMWare session) that you could run something like EZCacti on? Then just poll the F5 with Cacti via SNMP and you'll be away laughing.

     

     

    There's some templates floating around here for LTM/GTM specific stuff, and some shorter templates with specific graphs for some stuff I did for cacti as well to extend them.

     

     

    Hamish.
  • Sure I could use cacti or similar but that doesnt really solve my issue of being able to in cli see the approx bandwidth of a particular interface.

     

     

    Another problem with using cacti and similar is the latency of when the data will be displayed. I simply just want a snabshot of how many mbit/s a particular interface currently uses, not the 5 minute average etc.

     

     

    Something like "b show bandwidth " would be cool.
  • 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]

     

     

     

  • Argh! I'll have to fix this and add as attachment. Standby...
  • I cleaned the script up a little bit and added the ability to loop through all interfaces as well. It is posted in the wiki:

     

     

    http://devcentral.f5.com/wiki/default.aspx/AdvDesignConfig/BigIPRemoteInterfaceBandwidthMonitor.html
  • Good afternoon!

     

     

    Is this something that could be extended to give the total bandwidth utilized by a particular URL? Where could I go to find the answer to that?

     

     

    Thank you.

     

     

    TK

     

  • Hamish's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus
    Bandwidth per URL? Or bandwidth per Virtual Server?

     

     

    Per VS is quite easy. Its in the stats for each VS. You simply need to pull the correct OID. The cacti templates on devcentral can do this for you.

     

     

    Per URL is a bit harder. You'd need to use custom stats profiles and an iRule to do the counts and update the stats. Then pull the results with the correct SNMP OID (Or iControl). That would require a bit more thought, and would be a custom job per website.