From: meetmecall <in...@me...> - 2010-02-14 11:28:57
|
Fellow OpenBts fans and users, I have put some effort in writing an Asterisk based routine to generate lots of phone calls so the success rate of setting up calls can be investigated. It is a combination of a bash script and some Asterisk magic. This is the basic idea: - a flat file contains a list of numbers to call in sequence. - a bash scrip starts the routine. - a sip trunk is setup between the Asterisk machine used for setting up the calls and the OpenBTS machine. - the assumption is that - call files are generated. The call files sets up a local channel (actually just an Asterisk context) where the Asterisk magic takes place. - cdr (call detail records, the relevant data of a call) stores relevant info (google for a howto about how to setup mysql for asterisk cdr and how to setup phpmyadmin). The routine can be used without mysql for cdr and phpmyadmin as the frontend but it will make this routine much more useful. - the meetme() application is used to bridge the legs of the calls while using a conference room. When using newer version of Asterisk the meetme() app will not be available if Dahdi is not in place. assumptions: - zaptel or dahdi is in place. Meetme() needs a time source and zaptel or dahdi wil provide one. For the newer versions of Asterisk you need dahdi. - there is some music on hold available. There should be some files in /var/lib/asterisk/moh - the two servers (Openbts and the autodial server) are on the same network. It is actually an autodial routine with one leg that continues and the other leg will be renewed with every new call that is set up. It isn't as simple as I had hoped it would be and some Asterisk magic is involved, but I still hope that this is useful in some way. I really hope the OpenBootts can be used to set this up (mysql for cdr and phpmyadmin for the frontend of the database, dahdi, moh etc.). This would make live much more easier. I copy the working version from my own system. There are some Dutch named variables used and some variables that aren't needed anymore but for now I keep them in place so I'm sure that the routine will work. When there seem to be some response I will add it to the wiki and "translate" the dutch named variables. Some parameters are hardcoded while it seem logic to pass them on while starting the script. I hope this can be used to get some hard data about the quality in terms of succesrate of setting up calls, maintaining calls for a certain period and data about the sound quality provided by a openBTS based solution. The legal stuff is pretty standard so don't be worried about it. I'm looking forward to reaction, critics and compliments ;-) Erik ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; auteur : Erik de Wild ; company : Tripple-o : Your Asterisk migration partner ; e-mail : info at tripple-o.nl ; phone : 0031621830837 ; ; Rights : Tripple-o owns the rights to this dialplan ; Country : the Netherlands ; Time Zone : GMT +1 ; ; version : 1.0 ; date : 14 februari 2010 ; License : This dialplan is GPL3 licensed with the condition that ; this header is kept in place, credits are addressed and you don't charge ; money for the autodial solution as it is. Under this conditions you are allowed to use, change and ; redistribute it. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /////////////////////////////// /// example of flat file for numbers /var/lib/asterisk/agi-bin/ test_nummers //////////////////////////// 1006 1007 1008 1009 1010 1011 1012 1013 /////////////////////////// //// the bash script used to start the testing ////////////////////////// #!/bin/bash # read a file line by line #### # hardcoded variables so it runs without parameters #### account_code=1005 agent_nummer=1005 file=test_nummers x=0 lns=`wc -l $file` y=`expr "$lns" : '\([0-9]*\)'` regel=' ' while [ "$x" -lt "$y" ] do let x=x+1 ################## # add all numbers to one variable ################## regel=$regel$(head -n $x $file | tail -n 1)' ' done ################### # generate and move the file to /var/spool/asterisk/outgoing so the file is processed by Asterisk so the leg of the agent will be routed to conference room ################### echo $regel echo Channel: SIP/trunk-paris-lyon/$agent_nummer > /var/ spool/asterisk/meetmecall/accounts/$account_code/autodial_callfiles/ autodial.call echo MaxRetries: 0 >> /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial.call echo RetryTime: 60 >> /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial.call echo WaitTime: 30 >> /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial.call echo Context: autodial_agent >> / var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial.call echo Extension: s > > /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial.call echo Priority: 1 > > /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial.call echo SetVar: AGENT_NUMMER=$agent_nummer >> /var/spool/ asterisk/meetmecall/accounts/$account_code/autodial_callfiles/ autodial.call echo SetVar: ACCOUNT=$account_code >> / var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial.call echo SetVar: AANTAL_NUMMERS=$y >> / var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial.call echo ' ' > > /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial.call mv /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial.call /var/spool/asterisk/outgoing/ echo first call file ready sleep 15 # the 15 seconds gives time for the agent to pick up the phone before the first call comes in. ############# # generate a call file so the list with numbers and the relevant variables so they can be passed to Asterisk and use to set up calls to the numbers in the list ############# echo start making second callfile echo Channel: Local/ s@autodial_2 > /var/spool/ asterisk/meetmecall/accounts/$account_code/autodial_callfiles/ autodial_2.call echo MaxRetries: 0 >> /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call echo RetryTime: 60 >> /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call echo WaitTime: 30 >> /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call echo Context: autodial_fake_2 >> /var/ spool/asterisk/meetmecall/accounts/$account_code/autodial_callfiles/ autodial_2.call echo Extension: s >> /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call echo Priority: 1 > > /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call echo SetVar: AGENT_NUMMER=$agent_nummer >> /var/spool/ asterisk/meetmecall/accounts/$account_code/autodial_callfiles/ autodial_2.call echo SetVar: NUMMER_LIJST=$regel >> / var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call echo SetVar: ACCOUNT=$account_code >> /var/ spool/asterisk/meetmecall/accounts/$account_code/autodial_callfiles/ autodial_2.call echo SetVar: AANTAL_NUMMERS=$y >> / var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call echo SetVar: START_NUMMER=0 >> /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call echo SetVar: POSITION=1 >> / var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call echo ' ' > > /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call echo be ready to answer the calls ############ #move the call file to /var/spool/asterisk/outgoing so the call file is processed and the sequence of the calls of the list is started ############ mv /var/spool/asterisk/meetmecall/accounts/$account_code/ autodial_callfiles/autodial_2.call /var/spool/asterisk/outgoing/ $account_code echo calls are coming exit 0 ///////////////////////////////////// ////// /etc/asterisk/extensions.d/autodialer.conf //////////////////////////////////// ;############ ;# a call file pointing to a local channel always needs two legs. This fake leg makes Asterisk happy ;############ [autodial_fake_2] exten => s,1,Answer() exten => s,,NoOp(fake channel) exten => s,n,Wait(30000) exten => s,n,Hangup() [autodial_2] ;#################### ; You have to adjust this part to your needs. I use 4 digits numbers and the numbers are seperated by a space s every number takes ; 5 positions. Te lines below store the first 5 digits into variable TE_BELLEN_NUMMER (dutch for NUMBER_TO_CALL), strips the space in front so 4 digits are left ; removes the first 5 positions from the variable NUMMER_LIJST (dutch for NUMBER_LIST), set some cdr variables and makes the phone call ;################### exten => s,1,Answer() exten => s,n(start),Set(LENGTE_STRING=${LEN(${NUMMER_LIJST})}) ;;;;;;;;;; ; a check for the length of the variable has to be added. If ${LEN($ {NUMMER_LIJST})}=0 ; then routine can stp ;;;;;;;; exten => s,n,Set(TE_BELLEN_NUMMER=${NUMMER_LIJST:0:5}) exten => s,n,Set(TE_BELLEN_NUMMER=${TE_BELLEN_NUMMER:1:4}) exten => s,n,Set(NUMMER_LIJST=${NUMMER_LIJST:5:$[${LENGTE_STRING} - 5]}) exten => s,n,Set(CDR(accountcode)=${ACCOUNT}) exten => s,n,Set(CDR(userfield)=AD_${TE_BELLEN_NUMMER}) ;########### ; the g parameter keeps one leg alive after the other leg hangs up. ; the M parameter takes care of pointing directly to a macro after the call is picked up ;############ exten => s,n(bellen),Dial(SIP/trunk-paris-lyon/$[${TE_BELLEN_NUMMER}], 40,gM(enter_conference,${TE_BELLEN_NUMMER})) exten => s,n,wait(5) exten => s,n,ResetCDR(w) exten => s,n,NoOp(Call is finished and loop goes on) exten => s,n,Set(CDR(accountcode)=${ACCOUNT}) exten => s,n,Set(CDR(userfield)=AD_WRAPUP_TIME) exten => s,n,Hangup() ;###################### ; the "h" extension is executed after the call is hanged up on the callees side. The variables that has to be passed for the next call are added ; the call file is moved to /var/spool/asterisk/outgoing and context autodial_2 is executed again until all numbers are called. ;###################### exten => h,1,System(echo Channel: Local/ s@autodial_2 > /var/spool/ asterisk/meetmecall/accounts/${ACCOUNT}/autodial_callfiles/ autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,System(echo MaxRetries: 1 >> /var/spool/asterisk/meetmecall/accounts/${ACCOUNT}/ autodial_callfiles/autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,System(echo RetryTime: 60 >> /var/spool/asterisk/meetmecall/accounts/${ACCOUNT}/ autodial_callfiles/autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,System(echo WaitTime: 30 >> /var/spool/asterisk/meetmecall/accounts/${ACCOUNT}/ autodial_callfiles/autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,System(echo Context: autodial_fake_2 >> /var/ spool/asterisk/meetmecall/accounts/${ACCOUNT}/autodial_callfiles/ autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,System(echo Extension: s >> /var/spool/asterisk/meetmecall/accounts/${ACCOUNT}/ autodial_callfiles/autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,System(echo Priority: 1 > > /var/spool/asterisk/meetmecall/accounts/${ACCOUNT}/ autodial_callfiles/autodial_2call_${LEN($ {NUMMER_LIJST})}) $ exten => h,n,System(echo SetVar: AGENT_NUMMER=1005111 >> /var/spool/asterisk/ meetmecall/accounts/${ACCOUNT}/autodial_callfiles/autodial_2call_$ {LEN(${NUMMER_LIJST})}) exten => h,n,System(echo SetVar: NUMMER_LIJST=${NUMMER_LIJST} >> /var/spool/asterisk/meetmecall/accounts/${ACCOUNT}/ autodial_callfiles/autodial_2call_${LEN(${NUMMER_LIJST})}) ;exten => h,n,System(echo SetVar: START_NUMMER=${START_NUMMER} >> / var/spool/asterisk/meetmecall/accounts/${ACCOUNT}/autodial_callfiles/ autodial_2call_${LEN(${NUMMER_LIJST})}) ;exten => h,n,System(echo SetVar: POSITION=$ {POSITION} >> /var/spool/asterisk/ meetmecall/accounts/${ACCOUNT}/autodial_callfiles/autodial_2call_$ {LEN(${NUMMER_LIJST})}) exten => h,n,System(echo SetVar: ACCOUNT=1005 >> /var/ spool/asterisk/meetmecall/accounts/${ACCOUNT}/autodial_callfiles/ autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,System(echo ' ' > > /var/spool/asterisk/meetmecall/accounts/${ACCOUNT}/ autodial_callfiles/autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,System(echo ' ' > > /var/spool/asterisk/meetmecall/accounts/${ACCOUNT}/ autodial_callfiles/autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,System(echo ' ' > > /var/spool/asterisk/meetmecall/accounts/${ACCOUNT}/ autodial_callfiles/autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,NoOp( be ready to answer the next call) exten => h,n,System(cp /var/spool/asterisk/meetmecall/accounts/$ {ACCOUNT}/autodial_callfiles/autodial_2call_${LEN(${NUMMER_LIJST})} / var/spool/asterisk/outgoing/autodial_2call_${LEN(${NUMMER_LIJST})}) exten => h,n,NoOp(The next call is coming!!) [autodial_agent] exten => s,1,Answer() exten => s,n,Set(CDR(accountcode)=${ACCOUNT}) exten => s,n,Set(CDR(userfield)=AD_AGENT_${ACCOUNT}) ;exten => s,n,MusicOnHold() exten => s,n,Meetme(100,asM) exten => s,n,Hangup() [macro-enter_conference] ; used for the numbers that has been called exten => s,1,NoOp(start macro enter_conference in kamer 100 voor telefoonnummer ${ARG1}) ;exten => s,n,MusicOnHold() exten => s,n,Meetme(100) exten => s,n,MacroExit() ////////////////////// /// addition for the sip trunk in /etc/sip.sip.conf based on instruction on http://www.panoramisk.com/90/sip-trunk-with-asterisk/en/ ///////////////////// ////// on the machine with the autodial routine //////////////////// [trunk-paris-lyon] type=peer nat=no host=<IP number of OpenBTS machine> /////////////// // on the machine running OpenBTS /////////////// [trunk-lyon-paris] type=peer host=<IP number of the autodialer Asterisk box> nat=no call-limit=7 ; the number of available channels context=from-asterisk-paris ; context in use to "catch" calls coming in over the trunk. If you use the hotdeks routine (see the wiki) then you can call to normal numbers, otherwise you have to call to IMSI numbers. //////////////////////// // add room 100 to /etc/asterisk/meetme.conf exten => 100 (if you add it below the example room ;exten => 1234 it would be fine ) |