Forum Discussion

Stéphane_Degli1's avatar
Stéphane_Degli1
Icon for Nimbostratus rankNimbostratus
Dec 14, 2006

Event Notification format

Hello,

 

 

I need to get a way to disable new sessions to a pool member as result of a not down event.

 

I begin using the iControl API to write a servlet that will subscribe to member down events. It's working well. But I don't find how to parse the event notification I receive.

 

Indeed I get the pool and the pool member server which went down, and then a couple of long integer. I suspect them to respresent the event (node up or down) but I can't find their meaning.

 

Can anyone help me ? Is there an event description anywhere ?

 

 

Tanks a lot

 

 

Stéphane
  • Can you share the source code with me? I am just using the EventSubscription and EventNotification to do some job

     

  • Well the code is not very complicate, though my first try must be improved. I used java to acces the iControl API.

     

    You first need to have a subscription script.

     

    I used a HTTP servlet implementing this method :

     

     

    protected void subscribe() throws java.rmi.RemoteException

     

    {

     

    try

     

    {

     

    m_subscription = (iControl.ManagementEventSubscriptionBindingStub)

     

    new iControl.ManagementEventSubscriptionLocator().getManagementEventSubscriptionPort(new java.net.URL(m_endpoint));

     

     

    iControl.ManagementEventSubscriptionSubscriptionDetails[] sub_detail = {new iControl.ManagementEventSubscriptionSubscriptionDetails()};

     

     

    m_subscription.setTimeout(60000);

     

     

    sub_detail[0].setName("Subscription Nmae");

     

    sub_detail[0].setUrl("Listener's URL");

     

    sub_detail[0].setTtl(60);// Subscription TTL in seconds

     

    sub_detail[0].setMin_events_per_timeslice(10);

     

    sub_detail[0].setMax_timeslice(30);

     

    sub_detail[0].setEnabled_state(CommonEnabledState.fromString("Enabled");

     

    sub_detail[0].setUrl_credentials(new ManagementEventSubscriptionUserCredential(ManagementEventSubscriptionAuthenticationMode.fromString("None"), "","");

     

     

    String[] evtLst= { /* Events code List */ };

     

    ManagementEventSubscriptionEventType[] evt = new ManagementEventSubscriptionEventType[evtLst.length];

     

     

    for(int i=0; i{

     

    evt = ManagementEventSubscriptionEventType.fromString(evtLst);

     

    }

     

     

    sub_detail[0].setEvent_type_list(evt);

     

     

    ManagementEventSubscriptionSubscriptionStatus[] status = m_subscription.create(sub_detail);

     

     

    for(int i=0;i{

     

    System.out.println(status.getCode().toString() + " : " + status.getData());

     

    }

     

    }

     

     

    catch(java.net.MalformedURLException ex)

     

    {

     

    out.println("Invalid F5 url : " + ex.getMessage() + "\n");

     

    }

     

     

    catch(javax.xml.rpc.ServiceException ex)

     

    {

     

    out.println("Impossible to connect to the Big IP : " + ex.getMessage() + "\n");

     

    }

     

    }

     

     

     

    Then you need a SOAP listener. I used Apache Axis 1.4 (it seems 2.0 doesn't work with iControl). And then this servlet as the subscription listener. It simply outputs the notification received. But you may use it to do anything else :

     

     

    import java.text.*;

     

    import java.util.*;

     

    import java.io.*;

     

     

    import iControl.*;

     

     

    public class EventListener extends ManagementEventNotificationBindingStub

     

    {

     

    public EventListener() throws org.apache.axis.AxisFault {

     

    super();

     

    }

     

     

    public EventListener(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {

     

    super(endpointURL, service);

     

    }

     

     

    public EventListener(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault

     

    {

     

    super(service);

     

    }

     

     

     

    public void events_occurred(ManagementEventNotificationEventSource event_source, String subscription_id, ManagementEventNotificationEventData[] event_data_list, CommonTimeStamp time_stamp)

     

    {

     

    try

     

    {

     

    // Put some action here.

     

    }

     

     

    catch(java.rmi.RemoteException ex)

     

    {

     

    System.out.println("Impossible to connect to the Big IP " + ex.getMessage() + "\n");

     

    }

     

    }

     

     

     

    HIH