Forum Discussion

soymanue's avatar
soymanue
Icon for Nimbostratus rankNimbostratus
Apr 18, 2013

Sideband Connection Event Context

Hello

 

I need to call an external Web Service From APM to report a server that certain user is connected or disconnected.

 

I'm trying to do it with an iRule like this:

 

when RULE_INIT {

 

set servidor_destino "server.domain.int:7001"

 

 

set data "GET /RADIUS/rest/TLTF?name=mbm50002033 HTTP/1.0\r\n\r\n"

 

set conn [connect -timeout 1000 -idle 30 -status conn_status $servidor_destino]

 

if {$conn==""}{

 

log local0. "Conexion a Webservice fallida. No se puede conectar a $servidor_destino"

 

} else {

 

set send_info [send -timeout 3000 -status send_status $conn $data]

 

set rcv_data [recv -timeout 3000 -status recv_status 393 $conn]

 

log local0. "$data -> $rcv_data"

 

}

 

close $conn

 

}

 

 

When I try to save the iRule y get the error message :

 

"Command is not vallid in current event Context"

 

As I'm not applying the iRule to a Virtual Server, I think I can't use anything different from RULE_INIT line when HTTP_REQUEST o when CLIENT_ACCEPTED, can I?

 

Any idea?

 

Thank you

 

 

3 Replies

  • First thing, the RULE_INIT event is triggered when an iRule is updated, so it is never in context with traffic flow. That's the reason for the error message. You say that you want to send the message when a "certain user is connected or disconnected", but that this is not applied to a virtual server. How is the user connecting or disconnecting if not through a virtual server? Can you elaborate?

     

     

    Otherwise, you can certainly use the HTTP_REQUEST or CLIENT_ACCEPTED events to trigger sideband calls. To be APM-specific, you can make a sideband call from the ACCESS_POLICY_AGENT_EVENT event. Add an iRule event in your access policy, give it an ID value, and then add an iRule to the virtual server that looks something like this:

     

    
    when ACCESS_POLICY_AGENT_EVENT {
         switch [ACCESS::policy agent_id] {
              "MY_SIDEBAND_TRIGGER" {
                    this is where you would put your sideband call code, send the request, process the response, then arbitrarily stuff response values into access policy session values.
              }
         }
    }
    

     

     

    In this example, "MY_SIDEBAND_TRIGGER" is the ID value in the iRule event agent.

     

     

    Second, there are probably several ways to do what you need. While capturing disconnect events is a little trickier, all of the connect events are already stored in the access policy logs, so you could potentially harvest those. Equally, it looks like you're using RADIUS, so the built-in RADIUS accounting agent may also work for you.

     

  • Thank you

     

    So I have to add a iRule Event to the Access Policy.

     

    Where should I place it? After the Radius Authentication?

     

    In that case , how can I check if the session has finished from the APM? I can't do it with the Radius Server.

     

    I don't know how the iRule event Id works. Is that "Id" a number? I have another iRule Event created.