[asterisk-users] How to create a module

Steve Edwards asterisk.org at sedwards.com
Fri Jul 8 12:50:42 CDT 2011


On Fri, 8 Jul 2011, Adrian Abramovich wrote:

> We are using asterisk 1.4 and we use a Perl script to record some 
> specific calls. As far, everything is working well. I was thinking about 
> create a module in order to improve script's performance.

(I'm assuming you're executing your Perl script as an AGI.)

I'd vote for re-writing your Perl script in C.

Once you get past the small* hit for process creation and AGI environment 
setup, the execution time should be very similar between C code executing 
as a module and C code executing as an AGI.

The advantages of an AGI over a module are:

) You already know the AGI environment.

) Writing an AGI is probably an order of magnitude easier than writing a 
module. The 'environment' is much simpler, stable between Asterisk 
versions and better defined.

) Debugging an AGI is probably a couple of orders of magnitude easier than 
debugging a module because it is usually a single threaded process and you 
can (within obvious limitations) 'desk test' your code completely external 
to Asterisk.

) You'll get more support on the mailing lists. A lot more people know how 
to write and debug an AGI than know how to write and debug a module.

) When (not if) you hit a bug, it only takes out your AGI, not the entire 
Asterisk process. The damage is limited to a single call, not all calls in 
flight.

*) You can execute hundreds of AGIs written in C in the time it takes to 
load the Perl interpreter and parse your script.

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000



More information about the asterisk-users mailing list