Forum Discussion
Khamari_2736
Nov 28, 2011Nimbostratus
Global load balance between two servers (failover), with no preemption
Hello Group,
We would like to global load balance between two servers (failover), with no preemption. Meaning that the WideIP will resolve always to the same server until that server in q...
Khamari_2736
Jan 11, 2012Nimbostratus
This is another version of the perl script, that adds a feature that make sure that the backup server is out-of-the-manual resume at all time.
!/usr/bin/perl
================================================================
Description: Enable pool members that are manually disabled when their pool
is completely down, due to a manual resume feature.
Combining this with global availability, to Globally failover between two servers will
prevent possible flapping issues, if one of the servers goes unstable.
================================================================
Disclaimer:
This script is provided "AS IS", for non-commercial use, and you, its user, assume all risks when using it.
================================================================
use strict;
use warnings;
define system commands
my $snmpwalk_prog = '/usr/bin/snmpwalk -v2c -c baltimore localhost ';
my $pool_status = $snmpwalk_prog . 'gtmPoolStatusAvailState';
my $pool_member_order = $snmpwalk_prog . 'gtmPoolMbrOrder';
my $pool_member_enabled = $snmpwalk_prog . 'gtmPoolMbrEnabled';
my %pools;
get pool member order
open( my $pool_member_order_out, '-|', $pool_member_order )
or die "Failed to run command $pool_member_order : $!";
while (<$pool_member_order_out>) {
my ( $pool, $member ) = / "(.*?)" [.]ipv4[.] "(.*?)" /x;
my ($member_order) = / (\d) $ /x;
$pools{$pool}{MEMBER}{$member} = $member_order;
}
get pool member enable status
open( my $pool_member_enabled_out, '-|', $pool_member_enabled )
or die "Failed to run command $pool_member_enabled : $!";
while (<$pool_member_enabled_out>) {
my ( $pool, $member ) = / "(.*?)" [.]ipv4[.] "(.*?)" /x;
my ($status) = / INTEGER: \s+ ( enable | disable ) /x;
my $member_order = $pools{$pool}{MEMBER}{$member};
$pools{$pool}{$member_order} = $status;
}
get pool status
open( my $pool_status_out, '-|', $pool_status )
or die "Failed to run command $pool_status : $!";
while (<$pool_status_out>) {
get pool
my ($pool) = /"(.*?)"/;
pool status
my ($pool_status) = / INTEGER: \s+ ( green | red ) /x;
pool status is red or member 1 is disabled
if ( ( $pool_status eq 'red' )
or ( exists $pools{$pool}{1} and $pools{$pool}{1} eq 'disable' ) )
{
construct command
my $cmd =
"tmsh modify gtm pool $pool members modify { all { enabled }}";
run command
print "Running command: $cmd\n";
system($cmd) == 0 or die "$cmd failed";
}
}
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