Forum Discussion

Jack_Rodriguez1's avatar
Jack_Rodriguez1
Icon for Nimbostratus rankNimbostratus
Jan 31, 2007

Count number of connections from on source

We have a customer that is have issues with serveral sources creating loads of connections that brings that application to it's knees from time to time. We need an iRule that can track how many active connections from sources that currently have more then 10 connections. We have the below iRule that is providing most of what we need but we are trying to get an actual count of the active connections that exceed the threshold number of 10. For some reason we can't seem to get the total connections value to report out of the array. The logs will show the source IP that exceeds the 10 connection threshold but it logs one more then that threshold and then stops. It never logs more then 11 connections. Here is the current rule. Can you see where our logic is failing?

 

 

when RULE_INIT {

 

array set ::active_clients { }

 

set conn_threshold 10

 

}

 

 

when CLIENT_ACCEPTED {

 

set client_ip [IP::remote_addr]

 

if { [info exists ::active_clients($client_ip)] } {

 

set total_cons $::active_clients($client_ip)

 

if {$total_cons > $conn_threshold } {

 

log local0.info "$client_ip $total_cons using VS [IP::local_addr]"

 

return

 

} else {

 

incr ::active_clients($client_ip)

 

}

 

} else {

 

set ::active_clients($client_ip) 1

 

}

 

}

 

 

when CLIENT_CLOSED {

 

if { [info exists ::active_clients($client_ip)] } {

 

incr ::active_clients($client_ip) -1

 

if { $::active_clients($client_ip) <= 0 } {

 

unset ::active_clients($client_ip)

 

}

 

}

 

}

 

  • Joe, I was hoping you could help Jack and I out on this one. No one has accepted the challenge on this one? We just want to be able to count the number of concurrent connections for each source ip address. Once a threshold is reached (connections), we want to be able to log the offending ip address and to display how many cc connections it has. We really need some help with this one. Thanks, Rusty Hale