Colin Anderson
2006-Mar-29 10:08 UTC
[Asterisk-Users] OT: HOWTO: Query channel state on an Ateus Voice Blue GSM gateway
Because the VoiceBlue is only 4 channels and I am supporting 100 cell users, I needed a way to overflow calls to the PRI of all 4 channels are full. Unfortunately, there seems to be no built-in mechanism to determine if the gateway is full, so this script parses the output of "asterisk -rx sip show channels XXX.XXX.XXX.XXX" to determine the number of channels currently in use. Hope this helps someone. Notes: 1. Execute from /var/lib/asterisk/agi-bin as 'querygsmgateway.agi' 2. Replace .201 with the last dotted quad of your gateway's IP address (in this example, 192.168.1.201 is the IP of the gateway) 3. Assumes that the variable ${DIALSTRING} is set with the NAMA number of the mobile to call querygamgateway.agi: #!/bin/bash GSMCHANNEL=`asterisk -rx "SIP SHOW CHANNELS" | grep -a -A0 ".201"` CURRENTCHANNEL1=${GSMCHANNEL:55:7} CURRENTCHANNEL2=${GSMCHANNEL:118:7} CURRENTCHANNEL3=${GSMCHANNEL:181:7} CURRENTCHANNEL4=${GSMCHANNEL:244:7} TOTALCHANNELS=0 if [ "${GSMCHANNEL:55:7}" != "" ] then if [ $CURRENTCHANNEL1 = "ulaw" ] then TOTALCHANNELS=$((TOTALCHANNELS+1)) fi fi if [ "${GSMCHANNEL:118:7}" != "" ] then if [ $CURRENTCHANNEL2 = "ulaw" ] then TOTALCHANNELS=$((TOTALCHANNELS+1)) fi fi if [ "${GSMCHANNEL:181:7}" != "" ] then if [ $CURRENTCHANNEL3 = "ulaw" ] then TOTALCHANNELS=$((TOTALCHANNELS+1)) fi fi if [ "${GSMCHANNEL:244:7}" != "" ] then if [ $CURRENTCHANNEL4 = "ulaw" ] then TOTALCHANNELS=$((TOTALCHANNELS+1)) fi fi echo "SET VARIABLE GSMCHANNELS \"$TOTALCHANNELS\"" extensions.conf: exten => dial,1,AGI(/var/lib/asterisk/agi-bin/querygsmgateway.agi) 'Query the gateway exten => dial,3,Gotoif($[$["${DIALSTRING:7:3}" = "902"]]?4:20) 'Determine if the dialled # is a mobile. If so, use the gateway exten => dial,4,Gotoif($[${GSMCHANNELS} >= 4]?20:7)'If the gateway is currently full, dial using the PRI, otherwise exten => dial,5,ChanIsAvail(SIP/${SECONDARYDIALSTRING:7:7}@192.168.1.201) 'If the gateway is down, dial the PRI exten => dial,6,Dial(SIP/${DIALSTRING:7:7}@192.168.1.201,25,Tr) 'Dial using the gateway exten => dial,7,InsertVoicemailHandlerHere exten => dial,20,Dial(ZAP/g0/${DIALSTRING:7:7},25,Tr) 'Dial using the PRI exten => dial,21,InsertVoicemailHandlerHere exten => dial,106,Dial(ZAP/g0/${DIALSTRING:7:7},25,Tr) 'Dial using the PRI if the gateway is down exten => dial,107,InsertVoicemailHandlerHere
Michiel van Baak
2006-Mar-29 12:44 UTC
[Asterisk-Users] OT: HOWTO: Query channel state on an Ateus Voice Blue GSM gateway
On 10:08, Wed 29 Mar 06, Colin Anderson wrote:> Because the VoiceBlue is only 4 channels and I am supporting 100 cell users, > I needed a way to overflow calls to the PRI of all 4 channels are full. > Unfortunately, there seems to be no built-in mechanism to determine if the > gateway is full, so this script parses the output of "asterisk -rx sip show > channels XXX.XXX.XXX.XXX" to determine the number of channels currently in > use. Hope this helps someone.We use SetGroup and CheckGroup for this (I know, I should upgrade to 1.2 dialplan functions) -- Michiel van Baak michiel@vanbaak.info http://michiel.vanbaak.info GnuPG key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7E0B9A2D "Why is it drug addicts and computer afficionados are both called users?"