The best solution for your question is to implement this as an iControl solution. You can use the calling executable to request the aggregate number of connections from the backend servers and then disable the virtual from an iControl call.
If you want to do this with an iRule it is tricky but theoretically could be done with something like this
1. Every "n" requests, change the URI in the HTTP_REQUEST event to point to a "health" service that will return the metrics you want to work on in either headers or payload.
2. On the HTTP_RESPONSE, if the request was from the health service, then check the returned metrics.
3. If metrics say to stop connections, issue a "reject" command.
4. If metrics give a green light to continue, change the HTTP::uri back to the original value and issue a HTTP::retry. This will retry the HTTP request to the pool of servers. Keep in mind that you'll have to buffer the entire HTTP::request (headers) and the HTTP::payload and include both of them in the call to HTTP::retry.
Theoretically this could work but it has not been tested.
Hope this helps...
-Joe