[Asterisk-Dev] Integration of AGI and Management API

mattf mattf at vicimarketing.com
Tue Aug 10 20:04:53 MST 2004


Hello,

How many total clients do you expect to be using this system concurrently?

We are using the Asterisk Central Queue System
http://astguiclient.sourceforge.net/acqs.html to act as the go-between for
the client to the managerAPI. We have over 100 clients conncting to 3
Asterisk servers using a single MySQL server to send channel statuses and
action commands back and forth near real-time(we send over 100,000 manager
actions a day). Asterisk will get bogged down the more manager connections
you keep open(it will both slow down the server and cause manager output
pauses to become longer and more frequent), and having only a few acting as
a queue will improve performance and allow you to scale usage of your whole
system, and your client apps will never have direct contact with the
Asterisk server which has other benefits.

As for integrating AGI functionality, I haven't really seen a valid need for
this, what exactly are you trying to accomplish that you can't do with a
regular Originate or a Redirect Action command? You can very easily send a
sip phone into a meetme room by sending a manager Redirect or Originate
command and have the meetme room be associated with a specific dialplan
number.

Another thing, you can't use UniqueID because that will confuse things in
manager which already uses uniqueid as a variable. I do agree that there
does need to be an output variable within Manager aside from CallerID(I
suggest CallLabel) that will print out every time there is a manager event
for a specific call instance that was initiated or modified by a command
that had a CallLabel.(see link on last paragraph)

While I share your desire to modify the Manager API, if you look at how
often manager-related code changes from week to week and look at how many
places it is used in the asterisk code-base you would see what most of us
have already discovered: The managerAPI is a rapidly changing monster that
only a handful of core developers can understand and tame to do their
bidding. The rest of us have to find ways to get our applications to work
within what the code wizards have constructed. 

I tried changing the manager API code to simply add a new output field and
was quickly overwhelmed with the managerAPI and the fact that changing a
single line of manager code in one source file can screw things up in a
dozen other files. So I wrote up a whitepaper on what I wanted changed and
sent it to astricon, Hopefully someone will approve it for discussion:
http://www.freedomphones.net/Manager_API_modification_whitepaper.txt

Hope this helps,

MATT---


-----Original Message-----
From: David Pollak [mailto:dpp-asterisk at projectsinmotion.com]
Sent: Tuesday, August 10, 2004 5:37 PM
To: asterisk-dev at lists.digium.com
Subject: [Asterisk-Dev] Integration of AGI and Management API


Howdy,

I've been doing some development with Asterisk and AGI.  I'm using a
Java/J2EE application server for my business logic and database access.

In order to integrate my app server with Asterisk and AGI, my app server
opens a Manager API connection to the Asterisk server.  My dial plan is
basically AGI(passthrough.py) which fires off a Python script that opens a
socket connection to my app server and forwards the bytes from Asterisk to
the app server and from the app server to Asterisk.  Lots of open sockets...
lots of processes... lots of "selects" on the incoming ports to see the
traffic... all in all, no fun.

So, I've been looking over the Asterisk source and I had an idea... what if
there was a merger of the Manager API and AGI.  Here's specifically what I
was thinking:
- Extend the Management API to accept an "AGI" command which would contain a
Channel ID, an AGI command line, and a unique ID

Action: MAGI
Channel: SIP/12345
Command: meetme 1234
UniqueID: 22882292992929

- Add a ast_magi struct that contains an AGI command, a "unique ID", and a
pointer to the next ast_magi (i.e., the ast_magi is a linked list)
- Add a pointer to the MAGI struct into the ast_channel struct
- Add functionality to the ast_channel cleanup code to destroy any ast_magi
structs in the linked list
- Add helper routines to add an ast_magi to an ast_channel, get the first
ast_magi from a channel, etc.
- Significant updates to res_agi.c to check the channel for available
ast_magi structs and execute them as well as sending the output to the right
place (manager_event rather than right to the file descriptor)  Note that
MAGI responses are URL encoded to that responses that contain ':' newline
chars, etc. will fit on the Response line

Reponse after a MAGI command is executed:
MAGI: 22882292992929
Response: 200%20Success%20Result

- Add a flag to EVENT_FLAG for MAGI events

I've got the changes made to the codebase.  I'd like to get them accepted
back into the Asterisk distribution so that my copy of Asterisk is in sync
with the rest of the world.  What do I have to do to get the changes
accepted?

Thanks,

David 



More information about the asterisk-dev mailing list