Forum Discussion

dan_19334's avatar
dan_19334
Icon for Nimbostratus rankNimbostratus
Jan 19, 2010

ECV-Determine Pool Member Status

Hi, is there a good way to determine nodes that are available and not disabled from the command line? I am writing a custom monitor script and it seems I have to check two places to ensure that a Node is UP. Both a 'b pool show' and a 'tmsh show ltm pool members' requires me to parse multiple lines looking for both 'Availability' and 'State' to make sure the node is actually useable.

 

 

Status (from tmsh show pool)

 

Availability : available

 

State : enabled

 

 

Ideally I just want to know if our pool is at quorum, where say at least 4 out of 10 members are up (and not disabled). Sounds easy, but to me to do this requires a lot of parsing of the bigip tools output.

 

 

Thanks,

 

-Dan

8 Replies

  • Hi Dan,

     

     

    Can you clarify what you're trying to accomplish with the monitor? What do you want to do if X members of the pool are not up? It might be possible to handle the scenario without an external monitor.

     

     

    Thanks,

     

    Aaron
  • Aaron,

     

     

    We have a 'dummy' pool with each member representing an independent section of our application. This custom monitor is assigned to each of these member and determines if that section of the application is available, we then use an iRule to look at this dummy pool to see which areas are available and where to send the traffic to.

     

     

    The monitor actually needs to check to make sure that seven Pools are at quorum, and if so then marks that dummy pool member as up. If just one of the pools is not at quorum then mark the dummy member as down.

     

     

    Thanks,

     

    -Dan

     

     

  • Interesting. That dummy pool member idea was what I was going to suggest along with priority group activation. But thinking about it again, I'm not sure it would work easily as the higher priority pool members would still be selected even with the lower priority group was used.

     

     

    Do you have the actual servers defined in real pools which you select from the iRule? If so, could you use the active_members iRule command to check if the pool has enough members to use it? This would be in combination with a standard monitor configured on the actual pools.

     

     

    Else, I would think you could use a tmsh script to get the data you're looking for from the command line. Unfortunately, I haven't played around with the commands enough to suggest anything meaningful. You could try posting the question in the tmsh forum: http://devcentral.f5.com/Default.aspx?tabid=53&view=topics&forumid=70

     

     

    Aaron
  • Very interesting, indeed. We are currently checking for quorum in the iRule with active_members across all of the pools but as we increase user and ajax calls >5K we see a noticeable increase in LTM CPU from all of this checking. We are trying to decouple the monitoring from the user traffic so as not to increase monitoring when user traffic increases, and to have finite resources dedicated to monitoring.

     

     

    The core problem for this post is the inelegant method to determine Pool member status via all of the command line tools, including tmsh. I am looking for the best method to determine how many members of a pool are available to take traffic -- ie UP and not disabled. Currently it seems that you have to read in the output of these commands and look in two places to make sure the node can actually take traffic. I was hoping that someone has figured out a better way...

     

     

    -Dan

     

     

     

  • So you're looking for a particular object's (or pool of objects) enabled state and available state, in one output? This is a good candidate for a tmsh script. I don't have time today, but maybe tomorrow I can crank this out. please post back to let me know if this is what you are describing or if you had something else in mind.
  • Yes, looking to determine number of usable nodes in a Pool, essentially how many nodes in a pool are UP and not disabled. This is how I am currently doing it, and it begs for a better method:

     

     

     

    Routine for determining number of available nodes in a pool

     

    Args: Pool Name

     

    Returns: Number of available nodes in pool

     

     

    sub AvailableNodesInPool() {

     

     

    my $poolname = $_[0];

     

    my $poolcnt = 0;

     

    my $avail = 0;

     

    my $enable = 0;

     

     

    @tmshout = `/usr/bin/tmsh show ltm pool $poolname members`;

     

    while ($line = shift(@tmshout)) {

     

    skip the gobal pool info

     

    if ($line =~ /^Pool\s+Member:\s+${poolname}\s+(.*)/) {

     

    while ($line = shift(@tmshout)) {

     

    Check for "Availability : available" & "State : enabled"

     

    if ($line =~ /Availability\s+:\s+(.*)/) {

     

    $availability = $1;

     

    if ($debug) {print LOG "\n\tAvailability == $availability";}

     

    if ($availability =~ /available/) {$avail = 1;}

     

    } elsif ($line =~ /State\s+:\s+(.*)/) {

     

    $state = $1;

     

    if ($debug) {print LOG "\n\tState == $state";}

     

    if ($state =~ /enabled/) {$enable = 1;}

     

    } elsif ($line =~ /Reason/) {

     

    Done parsing data for this node, determine status

     

    if ($avail && $enable) {

     

    $poolcnt++;

     

    $avail = 0;

     

    $enable = 0;

     

    }

     

    }

     

    }

     

    }

     

    }

     

    return $poolcnt;

     

    }

     

     

  • Mark_Crosland_2's avatar
    Mark_Crosland_2
    Historic F5 Account
    In 10.1 you can do something like the script below. You still need to look at a couple values, but you can be more specific about what you are looking for and are not dependent on command output formatting.

     

     

    You could also up/down the dummy pool in this script based on status results.

     

     

    bash tmsh

     

    (tmos) create cli script pool-status.tcl

     

     

     

    Then call the script from somewhere.

     

    tmsh run cli script pool-status.tcl

     

     

    create script pool-status.tcl {

     

    proc script::run {} {

     

    set pool_names ""

     

    if { $tmsh::argc == 1 } {

     

    puts "enter one or more pool names"

     

    exit 1

     

    }

     

    set pool_names [lrange $tmsh::argv 1 end]

     

    foreach pn $pool_names {

     

    set total 0

     

    set usable 0

     

    get the status of each pool

     

    foreach obj [tmsh::get_status /ltm pool $pn detail] {

     

    if { [tmsh::get_type $obj] != "ltm pool-member" } {

     

    continue

     

    }

     

    incr total

     

    if { [tmsh::get_field_value $obj pool-member.status.availability-state] == "available" &&

     

    [tmsh::get_field_value $obj pool-member.status.enabled-state] == "enabled" } {

     

    incr usable

     

    }

     

    }

     

    example, require a quorum to consist of at least half of the members

     

    if { $usable > 0 && [expr 2 * $usable] >= $total } {

     

    puts "up: $pn"

     

    } else {

     

    puts "dn: $pn"

     

    }

     

    }

     

    }

     

    }

     

     

  • The tmsh::get_field_value does look to make this a lot easier. Thanks for info and script...just need to get to 10.1 now.

     

     

    -Dan