Use iRules to query number of active connections against a node
I am currently trying to automate a lot of the "out of the box" behaviour available on the BIG-IP using iRules which is, to say the least, quite a task. The reason for doing this is that we have an environment using DNS hostnames instead of IP addresses and because of that, we cannot configure nodes as pool members since this hard codes the node IP address as the pool member. I know there are other options like using iCall and GTM, but there's a whole lot of history and I'm trying to make the background short.
In a nutshell, I am trying to program the Least Connections (Member) load balancing algorithm using iRules, and resolving each hostname to an IP address as part of the HTTP_REQUEST event. Not pretty, I know.
My question is simple, but I'm not sure if the answer will be. I need a way to code the least connections algorithm. In order for that to work, I need to programatically query the number of active connections (for a virtual server and specific port...not including connections made from other virtual servers or other ports) against specific nodes.
I know this can be done using the TM shell by looking at the connection table, but I need it to be wrapped up in code that can be put inside an iRule.
Is there any way at all to do this using iRules?