Forum Discussion

Jerry_Beall_133's avatar
Jerry_Beall_133
Icon for Nimbostratus rankNimbostratus
Oct 02, 2013

Using Powershell to run > (Get-F5.iControl).LocalLBNodeAddressV2.set_monitor_rule Command

Im trying to set a monitor on a node via a script and I dont know the proper syntax to get it work. Below is the full command Im working with. I get the node name part correct but I have no idea to what is needed for the Monitor rules part. Thanks.

 

(Get-F5.iControl).LocalLBNodeAddressV2.set_monitor_rule('Node Name', ? )

 

3 Replies

  • The function definition for set_monitor rule is here. It looks like this:

     

    struct LocalLB.MonitorRule {
     LocalLB.MonitorRuleType type,
     int quorum,
     String [] monitor_templates
    };
    enum LocalLB.MonitorRuleType {
      MONITOR_RULE_TYPE_UNDEFINED,
      MONITOR_RULE_TYPE_NONE,
      MONITOR_RULE_TYPE_SINGLE,
      MONITOR_RULE_TYPE_AND_LIST,
      MONITOR_RULE_TYPE_M_OF_N
    };
    LocalLB.NodeAddressV2.set_monitor_rule.ashx(
        in String [] nodes,
        in LocalLB__MonitorRule [] monitor_rules
    );

    The parameters you pass in depend on the type of monitor you want to create. The types of monitor rules you create are defined in the documentation so I'd read the MonitorTypeRule API documentation and decide if you want a single monitor, a bunch of monitors that all need to succeed (MONITOR_RULE_TYPE_AND_LIST) or at least part of the monitors to succeed (MONITOR_RULE_TYPE_M_OF_N) for the system to mark the node as up.

     

    As for coding, you'll need to allocate the structures with the New-Object cmdlet. Here's a snippet of code that may get you going.

     

    Initialize-F5.iControl -hostname  -username  -password 
    $MonitorRule = New-Object -TypeName iControl.LocalLBMonitorRule;
    $MonitorRule.type = "MONITOR_RULE_AND_LIST";
    $MonitorRule.quorum = 1;
    $MonitorRule.MonitorTemplates = @("", "");
    (Get-F5.iControl).LocalLBNodeAddressV2.set_monitor_rule(
      @(""),
      @($MonitorRule)
    );

    Keep in mind that this wasn't tested so hopefully I didn't get any syntax errors in there. Also, you'll need to plug in your specific values for the placeholders.

     

    Hope this helps...

     

    -Joe

     

  • Thanks Joe for the prompt response and thats exactly what I needed to know! Im new to this F5 scripting and this helps me out a lot! Thanks Again!

     

    • Joe_Pruitt's avatar
      Joe_Pruitt
      No problem at all and glad to help! Check out the PowerShell page in the iControl wiki for a series of articles and code samples around using iControl with PowerShell. https://clouddocs.f5.com/api/icontrol-soap/PowerShell.html -Joe