Created
April 25, 2012 19:32
-
-
Save aserediuk/2492604 to your computer and use it in GitHub Desktop.
zxtm - list nodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use FindBin; | |
use lib "$FindBin::Bin"; | |
use ZXTM; | |
# Connect to the load balancer | |
my $conn = ZXTM->connect; | |
# Get a list of pools | |
my $res = $conn->getPoolNames(); | |
my @pools = @{$res->result}; | |
# Get the nodes for each pool | |
$res = $conn->getNodes( \@pools ); | |
# Build a hash %nodes: pool->[ node list ] | |
my %nodes; | |
@nodes{@pools} = @{$res->result}; | |
# Get the draining nodes for each pool | |
$res = $conn->getDrainingNodes( \@pools ); | |
# Build a hash %drainednodes: pool->[ drained node list ] | |
my %drainednodes; | |
@drainednodes{@pools} = @{$res->result}; | |
# Display nodes and mark if they're disabled | |
foreach my $pool ( sort ( keys ( %nodes))) { | |
print "$pool\n"; | |
foreach my $node ( @{$nodes{$pool}}) { | |
print "\t$node\t"; | |
if ( grep( /^$node/,@{$drainednodes{$pool}} ) ) { print "* disabled * "; } | |
print "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment