Forum Discussion

dhawal_138341's avatar
dhawal_138341
Icon for Nimbostratus rankNimbostratus
Dec 11, 2013

Create health monitor using iControl API

I'm trying to create a health monitor for my pool using iControl API. I was able to create a monitor template using the code below but I cannot figure out how to set 'Send String' and 'Receive String' properties.

 

Also, I don't understand what is the purpose of passing the common attributes. The below code just create a health monitor and doesn't assign it to the specified node.

 

$template = New-Object -TypeName iControl.LocalLBMonitorMonitorTemplate $template.template_name = $templateName $template.template_type = [iControl.LocalLBMonitorTemplateType]::TTYPE_HTTP

 

$templateAttributes = New-Object -TypeName iControl.LocalLBMonitorCommonAttributes $templateAttributes.parent_template = "http" $templateAttributes.dest_ipport = New-Object -TypeName iControl.LocalLBMonitorIPPort $templateAttributes.dest_ipport.address_type = [iControl.LocalLBAddressType]:: ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT $templateAttributes.dest_ipport.ipport = Get-Node -address "10.10.10.10" -port "80"

 

(Get-F5.iControl).LocalLBMonitor.create_template((, $template), (, $templateAttributes))

 

2 Replies

  • I'm able to set Send String and Receive String using the below code: $send_string = New-Object -TypeName iControl.LocalLBMonitorStringValue $send_string.type = [iControl.LocalLBMonitorStrPropertyType]::STYPE_SEND $send_string.value = $sendString $recv_string = New-Object -TypeName iControl.LocalLBMonitorStringValue $recv_string.type = [iControl.LocalLBMonitorStrPropertyType]::STYPE_RECEIVE $recv_string.value = $receiveString (Get-F5.iControl).LocalLBMonitor.set_template_string_property($templateName, ($send_string, $recv_string))
  • I think you found the solution. Creating monitors is sometimes a multi-call endeavor.