[asterisk-users] AMI perl daemon

Alex Balashov abalashov at evaristesys.com
Mon May 16 07:23:54 CDT 2011


On 05/16/2011 08:19 AM, vip killa wrote:

> If the script were called each time an extension were dialed in a
> dialplan for example, wouldn't each new instance of the script need to
> re-connect to AMI, run command, disconnect?

Well, yes, if you invoke a new instance of the script each time, that is 
what would happen.  The desired approach is to have some means of 
communicating with the running daemon to indicate to it that it should 
originate a call, perhaps via a control socket/API.

If your invocation is in the dial plan, the simplest thing to do would 
be to build a FastAGI server in Perl.  This CPAN module can save some work:

 
http://search.cpan.org/~jaywhy/Asterisk-FastAGI-0.02/lib/Asterisk/FastAGI.pm

Then have that process either maintain a persistent AMI connection, or 
open a new one each time if you don't feel like/don't know how to 
implement the asynchronous approach.

When you want to initiate a dial, just call:

    exten => ...,x,AGI(agi://some.server.ip/your_script)

Of course, you could also use call files if the script is executing on 
the same Asterisk server as the one on which the dials take place.

-- 
Alex Balashov - Principal
Evariste Systems LLC
260 Peachtree Street NW
Suite 2200
Atlanta, GA 30303
Tel: +1-678-954-0670
Fax: +1-404-961-1892
Web: http://www.evaristesys.com/



More information about the asterisk-users mailing list