Modify the FreePBX “Trunk balance module” ([login to view URL]) to check for congestion on trunks before using the trunk. Add functionality so that If more than X number of congestion messages have been detected within the last Y calls, within the last Z time frame in minutes on the trunk then it does not make the trunk available for use. Also modify the way ratio balancing works it so it equally balances all the trunks based on calls attempted at all, and not using the cdr table based on answered calls as it currently does (the cdr table does not update until after a call has ended). I think a new table or possibly even a local file will need to be used keep track of the # of calls on each trunk to balance them efficiently and can be updated every time a call is passed successfully through the trunk balance script.