Skip to content

Instantly share code, notes, and snippets.

@aserediuk
Created April 25, 2012 19:32
Show Gist options
  • Save aserediuk/2492604 to your computer and use it in GitHub Desktop.
Save aserediuk/2492604 to your computer and use it in GitHub Desktop.
zxtm - list nodes
#!/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