Forum Discussion

rdessert_76127's avatar
rdessert_76127
Icon for Nimbostratus rankNimbostratus
Dec 22, 2011

TCL error - TCP connection logging iRule

I'm using the below iRule to log TCP connections through my LTM (10.2.1).

 

when CLIENT_ACCEPTED {

 

set vip [IP::local_addr]:[TCP::local_port]

 

}

 

 

when SERVER_CONNECTED {

 

set client "[IP::client_addr]:[TCP::client_port]"

 

set node "[IP::server_addr]:[TCP::server_port]"

 

log local0.info "client: $client -> VIP: $vip -> Node: $node"

 

 

}

 

when CLIENT_CLOSED {

 

log local0.info "client: $client -> VIP: $vip -> Node: $node"

 

 

}

 

 

 

The LTM is logging an error message...

 

 

local/tmm1 err tmm1[4954]: 01220001:3: TCL error: TCP_Logging_All_Others - can't read "client": no such variable while executing "log local0.info "client: $client -> VIP: $vip -> Node: $node""

 

 

 

In spite of logging the error message, it still logs the CLIENT_CLOSED info.

 

 

Rule TCP_Logging :: client: 128.200.110.4%9:56334 -> VIP: x.x.x.x%9:443 -> Node: x.x.y.x%969:443

 

 

I'm trying to figure out why the error is ocurring and how to make it stop. I'm also curious why its actually logging a CLIENT_CLOSED event if it can't read the "client" variable.

 

 

Thanks for any help!

 

 

2 Replies

  • If no server connection is established, the client variable won't be set. So I assume that the log message you're getting for CLIENT_CLOSED isn't actually from that connection.

    You can use the clientside command to get the virtual server (or client's destination IP:port) in a serverside event like SERVER_CONNECTED instead of saving it in CLIENT_ACCEPTED.

    http://devcentral.f5.com/wiki/iRules.clientside.ashx

    
    when SERVER_CONNECTED {
    log local0.info "client: [IP::client_addr]:[TCP::client_port] -> VIP: [clientside {IP::local_addr}]:[clientside {TCP::local_port}] -> Node: [IP::server_addr]:[TCP::server_port]"
    
    }
    when CLIENT_CLOSED {
    log local0.info "client: [IP::client_addr]:[TCP::client_port] -> VIP: [IP::local_addr]:[TCP::client_port]"
    }
    

    Aaron