Forum Discussion

Maneesh_72711's avatar
Maneesh_72711
Icon for Cirrostratus rankCirrostratus
Mar 11, 2018

Displaying Client and Server Side connections via i-rule

I am trying to write an i-rule which gives my application users to see which user landed on which server. Got four pool members and below is what I have written.

when CLIENT_ACCEPTED {

table incr client-[IP::client_addr] 

table timeout client-[IP::client_addr] 21600 

table add -subtable client-tracking client-[IP::client_addr] 3600
}

when SERVER_CONNECTED {

table incr server-[IP::server_addr] 

table timeout server-[IP::server_addr] 21600

table add -subtable server-tracking server-[IP::server_addr] 21600
}

when HTTP_REQUEST {

if {[HTTP::uri] ne "/connections" } { return }

set response "Connections\r\n"

foreach ckey  [table keys -subtable client-tracking] {

    append response "$ckey = [table lookup $ckey]\r\n"
    `


    }

    foreach skey  [table keys -subtable server-tracking] {

    
`append response "$skey = [table lookup $skey]\r\n"

}

HTTP::respond 200 content $response Content-Type "text/plain" Connection Close

event disable
}

when CLIENT_CLOSED {

table delete -subtable client-tracking client-[IP::client_addr]

}

The above i-rule gives me details about how many client connections were received and how many server connections are there.

Connections client-X.Y.Z.P = 141

client-X.Y.Z.P = 38

server-X.Y.Z.P = 4

server-X.Y.Z.P = 15

server-X.Y.Z.P = 3

I want to see all in the same line basically Client-a.b.c.d=10--->Server-p.q.r.s=10. Can you help me how can I concatenate both of the together ?

Additionally I have cookie persistence on my VIP for 6 Hours, hence I chose 21600 seconds there is that correct or not required ?

4 Replies

  • Connections Table I get is like below.

     

    Connections

     

    client-X.Y.Z.P = 141

     

    client-X.Y.Z.P = 38

     

    server-X.Y.Z.P = 4

     

    server-X.Y.Z.P = 15

     

    server-X.Y.Z.P = 3

     

    I want to see all in the same line basically Client-a.b.c.d=10--->Server-p.q.r.s=10. Can you help me how can I concatenate both of the together ? Something like below: -

     

    client-X.Y.Z.P = 141 ----> server-X.Y.Z.P = 15 client-X.Y.Z.P = 38 ----> server-X.Y.Z.P = 3

     

  • My F5 is not directly exposed to Internet and all the traffic is controlled by proxy's in chaining.

     

    Question is how can I see both the Client and Server side in same line.

     

    Like Client-A made 5 connections to F5 and then finally landed on Server-B and has 3 current connections over it.

     

  • You should use LB::server addr and create connection table with IP::client_addr & LB selected server together. Of course, if there is a proxy before F5, you may not see the real client IP.

     

    https://devcentral.f5.com/wiki/iRules.LB__server.ashx Returns the IP address of the currently selected pool member. If no server was selected yet or all servers are down, returns null.

     

    You can extend connection table further with and info.