Forum Discussion

ltp_55848's avatar
ltp_55848
Icon for Nimbostratus rankNimbostratus
Aug 31, 2011

Perl iControl package

Hi All,

 

 

I've been working on this off and on for some time now and I thought others may find it useful. It's still somewhat rough around the edges and is still a work in progress but basic functionality for common tasks exists.

 

 

http://search.cpan.org/~ltp/iControl-0.01/lib/iControl.pm

 

 

Using the module, you can undertake simple tasks with (hopefully) less code like the following examples.

 

 

 

First; include the module and create a new iControl object;

use iControl;

my $ic = iControl->new( 
                        server          => 'myf5.company.com',
                        username        => 'username',
                        password        => 'password',
                        port            => 443,
                        proto           => 'https'
                );


Then, to list all virtual servers and their default pools;

foreach my $vs ($ic->get_vs_list()) {
        print "Virtual server: $vs, Pool: ", @{$ic->get_default_pool_name($vs)}[0], "\n";
}
Will output something similar to;

Virtual: my_virtual_name, Pool: my_pool_name
...
Or to print the statistics for each configured virtual server;

foreach my $vs ($ic->get_vs_list()) {
        print "\n\n$vs\n";
        my %stats = $ic->get_vs_statistics_stringified($vs);

        foreach (sort keys %{$stats{stats}}) {
                print "$_: $stats{stats}{$_}\n";
        }    
}
Will output for each virtual server:

virtual_server_name
STATISTIC_CLIENT_SIDE_BYTES_IN: 52688
STATISTIC_CLIENT_SIDE_BYTES_OUT: 30680
STATISTIC_CLIENT_SIDE_CURRENT_CONNECTIONS: 0
STATISTIC_CLIENT_SIDE_MAXIMUM_CONNECTIONS: 4
STATISTIC_CLIENT_SIDE_PACKETS_IN: 981
STATISTIC_CLIENT_SIDE_PACKETS_OUT: 682
STATISTIC_CLIENT_SIDE_TOTAL_CONNECTIONS: 637
STATISTIC_CURRENT_PVA_ASSISTED_CONNECTIONS: 0
...full stats truncated...
Feel free to let me know of any bugs you find. I'll be adding methods as I find a need for them and updating the module when I do. Cheers,
  • That looks really cool. Do you have any plans to support the v11 iControl SDK at some point?

     

     

    This would make a great addition to the iControl Codeshare:

     

    http://devcentral.f5.com/wiki/iControl.codeshare.ashx

     

     

    Aaron
  • Hi Hoolio,

     

     

    Thanks for the feedback.

     

     

    Unfortunately I'd been working on the package for a while before the release of v11, hence this release is v10-centric. I've noticed that the API changes quite significantly with v11, and that some of the uses for which I wrote this package (statistics collation) are now native in v11, so I kind of missed the boat with this release.

     

     

    My employer doesn't have any plans to upgrade to v11 in the short-term future, but I will be downloading the LTM VE and possibly doing some development work with it.

     

    • Grain_131632's avatar
      Grain_131632
      Icon for Nimbostratus rankNimbostratus
      HI.ltp,it's so cool... but ,I have a question,how to get ltm vs availability status ??....do you have same ideas?