[asterisk-users] need examples of asterisk and mysql integration

Steve Edwards asterisk.org at sedwards.com
Wed Apr 23 13:07:01 CDT 2008


>> At 04:13 PM 4/22/2008, you wrote:
>>
>>> I'm presently working on a project to build a scheduling system
>>> accessible by both web and phone.  on the web side one can query what
>>> items are available when by using the time or the item as a key then
>>> reserve for an available time slot.  reservations may also be modified
>>> by the user that made them or an admin.  Where may I find examples of
>>> doing similar things with asterisk?  all I've been able to find thus
>>> far is examples of how to store call detail records and voicemail
>>> using a database.

> Mike Trest - On Travel wrote:
>>
>> I suggest you look at writing a PERL  agi program to handle all of
>> the MYSQL / DB
>> access and just pass variables between your CONTEXT/dialplan.   I have done
>> a lot of these things.  You can get PERL examples for DBI  and use one of
>> provided  agi scripts as a prototype.

On Wed, 23 Apr 2008, Al Baker wrote:

> Why would you go to the trouble of writing a PERL AGI and take the
> Performance Hit of using AGI as opposed to using the  "built-in"  MYSQL
> from the dial plan ?

AGIs do not have a substantial "performance hit" and I think people need 
to get this misconception out of their heads.

Writing AGIs in a scripting, non-compiled language may be great for 
prototyping and proving concepts where performance is not expected to be 
an issue. Personally, I don't write AGIs in anything but C. It's the 
sharpest tool in my kit and I know it best.

A lowly 1.6GHz Celeron can execute over 100 AGIs per second. I strongly 
suspect that the "startup hit" will pale to the "interpretation hit" of 
the dialplan script quickly.

AGIs are a wonderful resource. You get the execution speed of an 
application (minus the usually insignificant startup hit) in a "sandbox" 
environment where you can't crash Asterisk and debugging is a couple of 
orders of magnitude easier. You can even write multi-threaded AGIs if 
needed. If you don't need to access the internals of Asterisk an AGI beats 
an application in my book. Maybe I should write one...

I guess some day I'm going to have to cobble up one of my 2,000 line AGIs 
(written in C) in "dialplan" so I can speak with authority from actual 
experience. However, the absence of facts has never stopped me from 
expressing an opinion :)

It seems that "compartmentalizing" a boat load of complex code in "a real 
language" (ducking quickly out of Tilghman's death glare) to be so natural 
to me for so many reasons I don't know where to start. So I won't. Unless 
asked :)

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