set monitor state

I am trying to set a pool member monitor state to disabled. I think that I am very close with this code:

private void SetMonitorState(string pool, string memberaddr, long memberport)

{

string[] pool_names = new string[] { pool };

LocalLBPoolMemberMemberMonitorState[][] monitor_states;

monitor_states = new iControl.LocalLBPoolMemberMemberMonitorState[2][];

monitor_states[0] = new LocalLBPoolMemberMemberMonitorState[1];

monitor_states[0][0].member = new iControl.CommonIPPortDefinition();

monitor_states[0][0].member.address = memberaddr;

monitor_states[0][0].member.port = memberport;

monitor_states[0][0].monitor_state = CommonEnabledState.STATE_DISABLED;

m_interfaces.LocalLBPoolMember.set_monitor_state(pool_names, monitor_states);

}

I get a “Object reference not set to an instance of an object.” error on the line -

monitor_states[0][0].member = new iControl.CommonIPPortDefinition();

I would be very grateful, if someone could point out my mistake.

You are close. You haven’t allocated a value for the monitor_states[ 0 ][ 0 ] value. This should work for you:

private void SetMonitorState(string pool, string memberaddr, long memberport)   
 {   
   string[] pool_names = new string[] { pool };   
   LocalLBPoolMemberMemberMonitorState[][] monitor_states;   
   // Allocate a 2-d array   
   monitor_states = new iControl.LocalLBPoolMemberMemberMonitorState[ 1 ][];   
   // Allocate the first dimensions value to a 1-d array of size 1   
   monitor_states[ 0 ] = new iControl.LocalLBPoolMemberMemberMonitorState[ 1 ];   
   // Allocate the value for the entry in the first element of the second dimension   
   monitor_states[ 0 ][ 0 ] = new iControl.LocalLBPoolMemberMemberMonitorState();   
   // Allocate the IPPortDefinition   
   monitor_states[ 0 ][ 0 ].member = new iControl.CommonIPPortDefinition();   
   monitor_states[ 0 ][ 0 ].member.address = memberaddr;   
   monitor_states[ 0 ][ 0 ].member.port = memberport;   
   monitor_states[ 0 ][ 0 ].monitor_state = CommonEnabledState.STATE_DISABLED;   
   m_interfaces.LocalLBPoolMember.set_monitor_state(pool_names, monitor_states);   
 }

BTW, sorry for how the forum munges brackets followed by numbers. I’m going to have to track that down one of these days.

-Joe

Thanks again Joe!

Regarding my post, “pool member forced offline”, I see where my mistake was. I was using LocalLBPoolMemberMemberSessionState. What I really wanted was LocalLBPoolMemberMemberMonitorState. I suspect that I was not communicating clearly in the post.

I’m very grateful for your help!!