Forum Discussion
3 Replies
Sort By
- hooleylistCirrostratusHi Naman,
when RULE_INIT { Create a list (instead of a datagroup) for testing set ::node_main [list \ "1.1.1.1" \ "2.1.1.1" \ "3.1.1.1" \ ] } when CLIENT_ACCEPTED { Compare active_nodes output with active_members log local0. "\[active_nodes -list \[LB::server pool\]\]: [active_nodes -list [LB::server pool]]" log local0. "\[\[llength active_nodes -list \[LB::server pool\]\]\]: [llength [active_nodes -list [LB::server pool]]]" log local0. "\[active_members -list \[LB::server pool\]\]: [active_members -list [LB::server pool]]" log local0. "\[\[llength active_members -list \[LB::server pool\]\]\]: [llength [active_members -list [LB::server pool]]]" Save the active members to a TCL list set members [active_members -list [LB::server pool]] Loop through the list and look up the IP address in the node_main "datagroup" foreach a_member $members { log local0. "Checking \$a_member: $a_member, [lindex $a_member 0]" Get the IP address from the "IP port" list item and compare it against the node_main datagroup if {[matchclass [lindex $a_member 0] eq $::node_main]}{ log local0. "Found $a_member in node_main datagroup" Found match, so exit foreach loop break } } }
when RULE_INIT { Create a list (instead of a datagroup) for testing set ::node_main [list \ "1.1.1.1:80" \ "2.1.1.1:80" \ "3.1.1.1:80" \ "10.41.135.3:80" \ ] } when CLIENT_ACCEPTED { Compare active_nodes output with active_members log local0. "\[active_nodes -list \[LB::server pool\]\]: [active_nodes -list [LB::server pool]]" log local0. "\[\[llength active_nodes -list \[LB::server pool\]\]\]: [llength [active_nodes -list [LB::server pool]]]" log local0. "\[active_members -list \[LB::server pool\]\]: [active_members -list [LB::server pool]]" log local0. "\[\[llength active_members -list \[LB::server pool\]\]\]: [llength [active_members -list [LB::server pool]]]" Save the active members to a TCL list set members [active_members -list [LB::server pool]] Loop through the list and look up the IP address and port in the node_main "datagroup" foreach a_member $members { Use string map to replace the space in the list element with a colon log local0. "Checking \$a_member: $a_member, [string map {" " :} $a_member]" if {[matchclass [string map {" " :} $a_member] eq $::node_main]}{ log local0. "Found [string map {" " :} $a_member] in node_main datagroup" Found match, so exit foreach loop break } } }
- Naman_65674NimbostratusHey Aaron,
- The_BhattmanNimbostratusFor those that want to use active_members -list command. Please note that "-list" option was added in 9.4.2.