Forum Discussion
sinamotamedi_15
Nimbostratus
I was getting a TCL error (TCL error: /Common/LogRule - can't read "client": no such variable while executing "log local0.info "Client $client -> VIP: $vip -> Node: $node"") when I created an iRule by copying/pasting the TCP logger rule in hoolio's first post and found I had to remove some quotation marks to properly set the variables. I'm running 11.6.0 Build 5.123.429. I also slightly modified it so it logs both when the connection is made and disconnected.
Here's what I used:
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 "Connected: Client $client -> VIP: $vip -> Node: $node"
}
when CLIENT_CLOSED {
log local0.info "Disconnected: Client $client -> VIP: $vip -> Node: $node"
}
This was a super helpful thread, thanks hoolio!
aries22
Aug 30, 2018Altocumulus
thank you so much sinamotamedi for your help! i edited the rule you gave and tested below which did not generate errors:
when CLIENT_ACCEPTED {
set vip [IP::local_addr]:[TCP::local_port]
set client [IP::client_addr]:[TCP::client_port]
}
when SERVER_CONNECTED {
set node [IP::server_addr]:[TCP::server_port]
log local0.info "Connected: Client $client -> VIP: $vip -> Node: $node"
}
when CLIENT_CLOSED {
log local0.info "Disconnected: Client $client -> VIP: $vip"
}
when SERVER_CLOSED {
if {[info exists node] and [info exists client]} {
log local0.info "Disconnected: Client $client -> VIP: $vip -> Node: $node"
} else {
do nothing
}
}