Perl Script to set and get pool member ratio on GTM

Hi all,

Without having to “re-invent the wheel”, does anyone have a perl script that sets or gets the ratio values on a wideip pool member? (or something similar that i can work with). I am looking for a script that can be run on the GTM itself and am planning to use it to adjust ratio values within a pool based on SNMP queries to a set of routers.

Regards,

Evan.

PS: The SNMP_DCA_BASE monitor functionality is not yet available within GTM, which is the reason why i am having to go down this path…

All,

Since i didnt get any replies, not sure if anyone is interested, but here is the working perl script. This may be used to set the ratio on a GTM pool member from the CLI.

Regards,

Evan.

!/usr/bin/perl
use SOAP::Lite;
----------------------------------------------------------------------------
 Validate Arguments
----------------------------------------------------------------------------
my $sHost = $ARGV[ 0 ];
my $sPort = $ARGV[ 1 ];
my $sUID = $ARGV[ 2 ];
my $sPWD = $ARGV[ 3 ];
my $sPool = $ARGV[ 4 ];
my $sMember = $ARGV[ 5 ];
my $sMember_Port = $ARGV[ 6 ];
my $sRatio = $ARGV[ 7 ];
my $sProtocol = "http";
sub usage()
{
        die ("Usage: ratio-set.pl Host | Port| uid | pwd | pool-name | member_IP | Member_Port | Ratio_value \n");
}
if ( ($sHost eq "") or ($sPort eq "") or ($sUID eq "") or ($sPWD eq "") or ($sMember_Port eq "") or ($sPool eq "") or 
($sMember eq "") or ($sRatio eq "") ) 
{
        usage();
}
----------------------------------------------------------------------------
 Transport Information
----------------------------------------------------------------------------
sub SOAP::Transport::HTTP::Client::get_basic_credentials
{
        return "$sUID" => "$sPWD";
}
$GlobalPoolMember = SOAP::Lite
        -> uri('urn:iControl:GlobalLB/PoolMember')
        -> readable(1)
        -> proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi");
----------------------------------------------------------------------------
 Attempt to add auth headers to avoid dual-round trip
----------------------------------------------------------------------------
eval { $GlobalPoolMember->transport->http_request->header
(
        'Authorization' =>
        'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '')
); };
eval { $GlobalPoolMember->transport->http_request->header
(
        'Authorization' =>
        'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '')
); };
----------------------------------------------------------------------------
 support for custom enum types
----------------------------------------------------------------------------
sub SOAP::Deserializer::typecast
{
        my ($self, $value, $name, $attrs, $children, $type) = @_;
        my $retval = undef;
        if ( "{urn:iControl}Common.EnabledState" == $type )
        {
                $retval = $value;
        }
        return $retval;
}
----------------------------------------------------------------------------
 Main logic
----------------------------------------------------------------------------
 Set Up correct input arrays for iControl call - set_ratio
----------------------------------------------------------------------------
        $MEMBER = 
        {
                address => $sMember,
                port => $sMember_Port,
        };
        
        $RATIOS = 
        {
                member => $MEMBER,
                ratio => $sRatio,
        };
        
        @List = 
        (
                [$RATIOS]
        );
        
----------------------------------------------------------------------------
 Send SOAP request to BIGIP/GTM
----------------------------------------------------------------------------
        $soapResponse = $GlobalPoolMember->set_ratio
        (
                SOAP::Data->name(pool_names => [$sPool]),
                SOAP::Data->name(ratios => [@List])
        );
        &checkResponse($soapResponse);
----------------------------------------------------------------------------
 checkResponse makes sure the error isn't a SOAP error
----------------------------------------------------------------------------
sub checkResponse()
{
        my ($soapResponse) = (@_);
        if ( $soapResponse->fault )
        {
                print $soapResponse->faultcode, " ", $soapResponse->faultstring, "\n";
                exit();
        }
}