Forum Discussion

Travis_Roberts_'s avatar
Travis_Roberts_
Icon for Nimbostratus rankNimbostratus
Oct 03, 2016

Including heath monitors when created GTM Pool.

I have a function that creates a GTM Pool (thanks again Joe Pruitt!), that I'd like to be able to modify to include a health monitor. I'm not really seeing what I think I need. I could be looking in entirely the wrong place too....

function Create-GTMPoolV2()
    {
        param([string]$name = $null,
              [string]$type = $null,
              [string]$lb_method = $null,
              [string]$vs_nameA = $null,
              [string]$vs_serverA = $null,
              [long]$order1 = $null,
              [string]$vs_nameB = $null,
              [string]$vs_serverB = $null,
              [long]$order2 = $null);
        if ($name -and $type -and $lb_method -and $vs_nameA -and $vs_serverA -and $order1 -and $vs_nameB -and $vs_serverB -and $order2)
            {
                 Create pool
                $pool_id = New-Object -TypeName iControl.GlobalLBPoolID;
                $pool_id.pool_name = $name;
                $pool_id.pool_type = $type;
                $pool_idA = (, $pool_id);
                $lb_methodA = (, $lb_method);
                (Get-F5.iControl).GlobalLBPoolV2.create($pool_idA, $lb_methodA);
                 Add Members
                $member1 = New-Object -TypeName iControl.GlobalLBVirtualServerID;
                $member1.name = $vs_nameA;
                $member1.server = $vs_serverA;
                $member2 = New-Object -TypeName iControl.GlobalLBVirtualServerID;
                $member2.name = $vs_nameB;
                $member2.server = $vs_serverB;
                $memberA = ($member1, $member2);
                $memberAofA = (, $memberA);
                $orderA = ($order1, $order2);
                $orderAofA = (, $orderA);
                (Get-F5.iControl).GlobalLBPoolV2.add_member($pool_idA, $memberAofA, $orderAofA);
            }
    }

Create-GTMPoolV2 -name $pool -type $type -lb_method $lbmethod -vs_nameA $vserverA -vs_serverA $serverA -order1 1 -vs_nameB $vserverB -vs_serverB $serverB -order2 2

2 Replies

  • Lets simplify this a bit.....

     

    I have a pool named pool-test that has two members (vs-test1 and vs-test2) that i would like to apply the gateway-icmp health monitor to through powershell. Maybe I'm not understanding the terminology, but wouldn't/shouldn't this work:

     

    (Get-)

     

     

    I've found the Documentation but its not really clear to me what needs to be included. Would it be easier to do this at the time of pool creation? If so, how? I'm not finding any documentation on this so any help would be much appreciated.

     

  • The GTM Pool APIs work similar to the LTM Pool APIs with regards to monitors. You must first create the Pool, which it seems you have done, and then set any associated attributes - including monitors.

     

    For GTM, you can do this at the pool level with the set_monitor_rule() or at an individual member level with the set_member_monitor_rule() call.

     

    Both of these APIs take in a MonitorRule structure which defines the behavior of how the monitor results are interpreted. It takes in a Type which indicates what triggers an action (one monitor failing, and AND condition for all monitors, or a "M of N" test). The quorum parameter is uses for the "M of N" Type. And lastly is an array of Monitor templates to apply for that rule. This is where you would pass in the template name for the monitor you wish to add.

     

    I've written a few samples on Monitor instances in the past. This one comes to mind for LTM, but applying the monitor uses the same process as the GTM pool.

     

    If you don't have a monitor created, you can use the GlobalLB.Monitor interface and associated methods.

     

    For the last question on whether it would be easier to do it all in one shot. The answer is likely yes, but we designed it this way to allow us to be able to make our APIs more flexible and not so brittle to compatibility issues. What happens if the product changes for some reason and needs to add an additional field for a monitor associated with a Pool. Then we have to create a new .create() method. Eventually you will end up with an API with a bunch of different create methods over time leading to confusion. In this case, it likely won't be the issue but there were others where it has absolutely been the case. Sorry this seems a bit convoluted, but once you get a solution, it will continue working for you.

     

    Hope this helps...