Forum Discussion

Scott_Jarboe_31's avatar
Scott_Jarboe_31
Icon for Nimbostratus rankNimbostratus
Mar 24, 2017

PowerShell - Add Health Monitor to Pool

Hi there,

 

I am looking for the PowerShell way to do the following: 1. Go to Local Traffic > Pools > Select a Pool 2. Select "http" from "Available Health Monitors" 3. Press << to add the health monitor 4. Press "Update" to apply change.

 

I know how to go so far as to access the F5 and create the Node and Pool, but I'm not sure how to apply the health monitor to the pool.

 

Warm regards, Scott

 

1 Reply

  • Assuming you are using the iControl PowerShell cmdlet's, here's something that should get you going.

    ----------------------------------------------------------------------------
    function Associate-MonitorWithPool()
    
      Description:
        This function will associate a monitor template with the specified pool.
    
      Parameters:
        PoolName    - The Pool name to target.
        MonitorName - The Monitor Template name to associate with the given pool.
    ----------------------------------------------------------------------------
    {
      param(
        [string]$PoolName,
        [string]$MonitorName
      );
    
      $monitor_association = New-Object -TypeName iControl.LocalLBPoolMonitorAssociation;
      $monitor_association.pool_name = $PoolName;
      $monitor_association.monitor_rule = New-Object -TypeName iControl.LocalLBMonitorRule;
      $monitor_association.monitor_rule.type = "MONITOR_RULE_TYPE_SINGLE";
      $monitor_association.monitor_rule.quorum = 0;
      $monitor_association.monitor_rule.monitor_templates = (, $MonitorName);
    
      $(Get-F5.iControl).LocalLBPool.set_monitor_association(
        (, $monitor_association)
      );
    
      Write-Host "Monitor '$MonitorName' Is Associated With Pool '$PoolName'";
    }