Forum Discussion

Hurricane_1983_'s avatar
Nov 02, 2017

log some message when servers connections exceed a connection value

Hi,

Is there anyway to send an alert message or writing the some kind of log message to ltm file when pool member active connection exceed 100 connections. the below irule is counting the connections coming into VS and writing "log limit" message to ltm file when active connection passed to max connection. I want to apply this for pool members instead of virtual server.

when RULE_INIT {

Set a global max for number of concurrent TCP connections set ::max_connections 2

Set an HTML response to sent to clients who make a request while the VIP is over the max connection count set ::html_content "over limit"

Print debug messages to /var/log/ltm? 1=yes, 0=no set ::debug 1

Initialize a counter for active connections (don't modify this) set ::active_connections 0 } when HTTP_REQUEST {

If we're over the limit for this connection, send a response if {$::active_connections > $::max_connections}{

   Send a response
  HTTP::respond 200 content $::html_content

   Close the connection
  TCP::close

   Log a message to /var/log/ltm if debug is enabled
  if {$::debug}{log local0. "Over limit (current/max: $::active_connections/$::max_connections). Sent response to [IP::client_addr]"}

We're not over the limit, so check if this is the first HTTP request on the TCP connection.

} elseif {[HTTP::request_num] == 1}{ set validrequest 1 Increment the TCP connection count. incr ::active_connections 1 } }

when CLIENT_CLOSED { A connection was closed, so decrement the global counter if {$validrequest == 1}{ incr ::active_connections -1 } }

9 Replies

  • You can set a connection limit on a pool member in the pool settings.

     

    Once the connection limit for a member is exceeded, there is a message written into the LTM logs.

     

    Does this help?

     

  • You can incorporate LB::Select option to know which pool members were selected. https://clouddocs.f5.com/api/irules/LB__select.html

     

    Code

    when HTTP_REQUEST { log local0. "lbserveraddr: [LB::server addr]" check if serverside connection had previously been established if { [LB::server addr] eq "" }{ if no serverside connection had previously been established, force one so the iRule has the info required to insert a destination-specific header eval [LB::select] } switch [LB::server addr] { "172.16.5.80" { HTTP::header replace Host www1.customer.com } "172.16.5.81" { HTTP::header replace Host www2.customer.com } "172.16.5.82" { HTTP::header replace Host www3.customer.com } } }

     

  • Hi Blakley,

     

    I think connection limit optioan but i dont only want to get a message while pool members reached specified connection limit.

     

    • Simon_Blakely's avatar
      Simon_Blakely
      Icon for Employee rankEmployee

      When pool members hit their connection limit, no further connections will be sent to that pool members. The connections will be sent to pool members that have not reached the connection limit. Once all pool members have reached their connection limit, the virtual server will respond with a reset (no pool members available). However, if you set a fallback host in the http profile, the request will be redirected there.

       

    • amintej's avatar
      amintej
      Icon for Cirrus rankCirrus

      Hello S Blakely, when the VS respond with a reset, a message is writing in the log ? I could not find it.

       

    • Simon_Blakely's avatar
      Simon_Blakely
      Icon for Employee rankEmployee

      I thought there was a log message when a pool member reached the connection limit. I'll need to check, but it will be a couple of days.

       

  • Hello,

     

    Could you please show an example of logging in LTM when connection limit is reached ? I don't see the error however I am detecting connection reset due to the limit. I have no irule configured and default logging configuration, version F5 BIG-IP 12.1.2 Build 0.93.249 Engineering Hotfix

     

  • Hi,

     

    Is there an update on how the logs look when a pool member has reached maximum connection limit?

     

    Regards, Murali