[asterisk-users] Concurrent calls including mysql taking lot of time for execution

covici at ccs.covici.com covici at ccs.covici.com
Wed Oct 21 20:54:52 CDT 2009


Steve Edwards <asterisk.org at sedwards.com> wrote:

> >> On Wed, 21 Oct 2009, Steve Edwards wrote:
> >>
> >>> I'd take a look at using AGIs written in C. They make nice little 
> >>> building blocks. They execute very quickly and can cleanup your 
> >>> dialplan.
> >>
> >> And you can debug them (AGIs in any language) from the command line 
> >> completely outside of Asterisk.
> 
> On Wed, 21 Oct 2009, covici at ccs.covici.com wrote:
> 
> > OK, are there include files available for the appropriate functionality? 
> > Sounds like it might be very nice.
> 
> If you're referring to "debugging outside of Asterisk," it's dead obvious 
> -- once you know the "secret."
> 
> The AGI protocol is just communications over STDIN and STDOUT in a 
> specific format.
> 
> Thus, running outside of Asterisk just means feeding the right stuff going 
> in and observing the right stuff coming out.
> 
> For example:
> 
>  	./block-ani <dummy-input-for-block-ani
> 
> where dummy-input-for-block-ani contains:
> 
> agi_accountcode:
> agi_callerid: 1234567890
> agi_calleridname: sedwards
> agi_callingani2: 0
> agi_callingpres: 0
> agi_callingtns: 0
> agi_callington: 0
> agi_channel: SIP/201-09456478
> agi_context: newline
> agi_dnid: *
> agi_enhanced: 0.0
> agi_extension: *
> agi_language: en
> agi_priority: 1
> agi_rdnis: unknown
> agi_request: block-ani
> agi_type: SIP
> agi_uniqueid: 1195070681.28
> 
> 200 result=1 (5555551212)
> 200 result=1 (localhost)
> 200 result=1 (example)
> 200 result=1 (example)
> 200 result=1 (example)
> 
> The first "block" is the standard AGI environment. The second block is 
> specific to this AGI and supplies the answers to the AGI requests "GET 
> VARIABLE ANI, "GET VARIABLE DATABASE-SERVER," "GET DATABASE-DATABASE," 
> "GET DATABASE-USERNAME," and "GET DATABASE PASSWORD."
> 
> I prefer to use an executable script so I can include comments. The script 
> looks like:
> 
> # agi-environment.sh
> 
> # the standard AGI environment variables
>          echo "agi_accountcode: "
>          echo "agi_callerid: 1234567890"
>          echo "agi_calleridname: sedwards"
>          echo "agi_callingani2: 0"
>          echo "agi_callingpres: 0"
>          echo "agi_callingtns: 0"
>          echo "agi_callington: 0"
>          echo "agi_channel: SIP/201-09456478"
>          echo "agi_context: newline"
>          echo "agi_dnid: *"
>          echo "agi_enhanced: 0.0"
>          echo "agi_extension: *"
>          echo "agi_language: en"
>          echo "agi_priority: 1"
>          echo "agi_rdnis: unknown"
>          echo "agi_request: block-ani"
>          echo "agi_type: SIP"
>          echo "agi_uniqueid: 1195070681.28"
>          echo ""
> 
> # cruft specific to my AGI
> 
> # AGI Rx << GET VARIABLE "ANI"
>          echo "200 result=1 (5555551212)"
> # AGI Rx << GET VARIABLE "DATABASE-SERVER"
>          echo "200 result=1 (localhost)"
> # AGI Rx << GET VARIABLE "DATABASE-DATABASE"
>          echo "200 result=1 (example)"
> # AGI Rx << GET VARIABLE "DATABASE-USERNAME"
>          echo "200 result=1 (example)"
> # AGI Rx << GET VARIABLE "DATABASE-PASSWORD"
>          echo "200 result=1 (example)"
> 
> # (end of agi-environment.sh)
> 
> And you use it like:
> 
>  	./agi-environment.sh | ./block-ani
> 
> or
> 
>  	./agi-environment.sh >dummy-input-for-block-ani
>  	./block-ani <dummy-input-for-block-ani
> 
> Since I'm an "old-school" C programmer, I use emacs as my editor. I fire 
> up gdb (the GNU C (amongst other languages) debugger) in a window, give it 
> a command like "b main; r <dummy-input-for-block-ani" and I can step 
> through my program line by line, examining and changing variables at will.
> 
> Beats the hell out of peppering your code with prints/puts/echos and 
> crossing your fingers.
> 
> -- 
> Thanks in advance,
> -------------------------------------------------------------------------
> Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
> Newline                                              Fax: +1-760-731-3000
> 
> _______________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> 
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
OK, but how do write the C program -- the Perl and php agis have defined
functions for the agi commands, how do you do this in c?


-- 
Your life is like a penny.  You're going to lose it.  The question is:
How do
you spend it?

         John Covici
         covici at ccs.covici.com



More information about the asterisk-users mailing list