[asterisk-users] Detecting Busy AGI Extensions?

Matthew Rubenstein email at mattruby.com
Thu Oct 5 07:18:44 MST 2006


        I'm initiating a bunch of calls from Perl script that sends
callfiles into the outgoung queue. A callfile dials a phone# thru a SIP
gateway to the PSTN, then connects it to an extension which is mapped to
an AGI script (also Perl, but a separate file) that plays a recording
(and listens for some IVR). The initiating script loops to start the
next call faster than the AGI extension finishes the call/IVR. So I
expect that the initiating script will get lots of busy messages from a
single extension, and therefore fail to call until the extension is free
again, or at least block with a full outgoing spool, though I have lots
of extra SIP outgoing capacity. I want the initiating script to start
several parallel calls.

	So I could make the initiating script specify a loop of predefined
extensions, each pointing to a copy of the AGI that manages the actual
call content once connected. But I'm not sure how the initiating script
can get the available status of an extension before specifying the
extension in the callfile or skipping to the next possible  extension.
The Asterisk::AGI module invoked in the initiating script doesn't have
the AGI context of the script to which it's passed, which makes a
catch-22. The manager interface connected to the initiating script
doesn't seem to support the ExtensionState command properly, which just
returns -1 (invalid) unless the extension has a hint, in which case it
always returns 4 (unavailable), regardless of the state. The manager
interface does catch NewExtension events when the AGI on the extension
is actually running, but not when it stops, so the initiating script can
register that the AGI script is busy, but not when it becomes available
again. And I don't see any way for the initiating script to act like a
dialplan to jump to a label on extension busy, or a way to
programmatically refer to the "next extension" in a context.

	I think I'd rather use queues for flexibility, scalability, etc.
However, it looks like creating a queue requires direction indirectly
through Agents, virtual connectors into which each AGI script handling
the actual call content would have to login. I don't know how to make an
AGI script login as an Agent, or how to specify a queue that connects
live outgoing channels to a pool of waiting extensions.

	Thanks for your advice.
-- 

(C) Matthew Rubenstein



More information about the asterisk-users mailing list