For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

thennessey_2290's avatar
thennessey_2290
Icon for Nimbostratus rankNimbostratus
Oct 27, 2015

Set existing monitor on existing node in Powershell - F5 Big-IP

I know how to create a new node in Powershell. I've read you cannot apply a health monitor upon creation. So how can I add a health monitor afterwards? The name of the node is "TestNode1" and the health monitor is default http.

 

Below is what I'm playing with. I think I'm close up until the second argument. No idea what to do there. Thanks for any help!

 

$ic.LocalLBNodeAddressV2.set_monitor_rule("TestNode1",$ic.LocalLBMonitorRule.monitor_rule("http"))

 

6 Replies

  • Hi, have you seen this link?

    https://devcentral.f5.com/questions/using-powershell-to-run-get-f5icontrol-locallbnodeaddressv2set_monitor_rule-command

    I am no expert, this is my test and it works for me:

    Add-PSSnapIn iControlSnapIn
    Initialize-F5.iControl -HostName 192.168.1.245 -Credentials (Get-Credential)
    
    $MonitorRule = New-Object -TypeName iControl.LocalLBMonitorRule
    $MonitorRule.type = "MONITOR_RULE_TYPE_SINGLE"
    $MonitorRule.monitor_templates = @("icmp")
    
    (Get-F5.iControl).LocalLBNodeAddressV2.set_monitor_rule(@("10.10.10.10"), @($MonitorRule))
    
    Remove-PSSnapIn iControlSnapIn
    
  • Thanks, I had seen that page but it creates the monitor, it doesn't apply an existing monitor. I will give your script a try. Is there a reason you use arrays (@) in this script? Is it necessary to apply a single monitor to a single node? Thanks for the help.

     

    • cjunior's avatar
      cjunior
      Icon for Nacreous rankNacreous
      It sets the icmp monitor as a single monitor to node, it is not creating a new one. My arrays were used just to make it clear that the method signature. Usually, I don't need to monitor the node, I do that in the pool. I hope to have it understood. Regards.
  • I am getting this error. This node does exist in common.

     

    $MonitorRule = New-Object -TypeName iControl.LocalLBMonitorRule $MonitorRule.type = "MONITOR_RULE_TYPE_SINGLE" $MonitorRule.monitor_templates = @("icmp") (Get-F5.iControl).LocalLBNodeAddressV2.set_monitor_rule(@("172.22.130.71"), @($MonitorRule))

     

    Exception calling "set_monitor_rule" with "2" argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/NodeAddressV2::set_monitor_rule() Exception: Common::OperationFailed primary_error_code : 16908342 (0x01020036) secondary_error_code : 0 error_string : 01020036:3: The requested Node (/Common/172.22.130.71) was not found." At line:4 char:79 + (Get-F5.iControl).LocalLBNodeAddressV2.set_monitor_rule(@("172.22.130.71"), @($M ... + ~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SoapHeaderException

     

  • I used the node's name instead of IP and it worked. Strange. In other cases, doing other operations, I had to use the node's IP. Any ideas why? Thanks for the help with getting this working. Much appreciated.