Just a suggestion.
I’ve never used a sangoima card, but I assume you can do this
Create two groups of lines. one with 5 of the lines and another group with the remaining three.
in your dial plan for your outbound trunk, dial group 1 if that fails, system() an email script and dial through group 2. Your email script could also include a count on the active channels.
for example
[code][outbound-context]
; Call any number longer than 4 digits via the Dahdi trunk
exten => _XXXXX.,1,NoOp(External Call)
; Try to call on group 1 (first 5)
exten => _XXXXX.,n,Dial(DAHDI/g1/${EXTEN})
; If we are here, then the trunk is full
; Run our script and fork it off the current process so we dont have to wait around with a &
exten => _XXXXX.,n,System(/usr/local/emailsomethingclever.sh&)
; And place the call out on our remaining lines
exten => _XXXXX.,n,Dial(DAHDI/g2/${EXTEN})
[/code]
You can also use it on IP trunks using call-limit=x in sip.conf
[sip-trunk-1]
type=peer
username=mysipuid
password=donttell!!!!
host=sip.mysipprovider.org
call-limit=5
; other relevant stuff
[sip-trunk-2]
type=peer
username=mysipuid
password=donttell!!!!
host=sip.mysipprovider.org
call-limit=3
; other relevant stuff
and then call out in the same manner
[outbound-context]
; Call any number longer than 4 digits via the SIP trunk
exten => _XXXXX.,1,NoOp(External Call)
; Try to call on group 1 (first 5)
exten => _XXXXX.,n,Dial(SIP/sip-trunk-1/${EXTEN})
; If we are here, then the trunk is full
; Run our script and fork it off the current process so we dont have to wait around with a &
exten => _XXXXX.,n,System(/usr/local/emailsomethingclever.sh&)
; And place the call out on our remaining lines
exten => _XXXXX.,n,Dial(SIP/sip-trunk-2/${EXTEN})
Done from within the dial plan, you wouldnt need to run the script from every call
Hope this helps
Cheers
Chris