System information
AGI Variants
There are a few variants of AGI that differ primarily in the method used to communicate
with Asterisk. It is good to be aware of all of the options so you can make the best choice
based on the needs of your application.
Process-Based AGI
Process-based AGI is the simplest variant of AGI. The “quick-start” example at the
beginning of this chapter was an example of a process-based AGI script. The AGI script
is invoked by using the AGI() application from the Asterisk dialplan. The application
to run is specified as the first argument to AGI(). Unless a full path is specified, the
application is expected to exist in the /var/lib/asterisk/agi-bin/ directory. Arguments to
be passed to your AGI application can be specified as additional arguments to the
AGI() application in the Asterisk dialplan. The syntax is:
AGI(command[,arg1[,arg2[,...]]])
Ensure that your application has the proper permissions set such that
the user the Asterisk process is running as has permissions to execute
it. Otherwise, AGI() will fail.
Once Asterisk executes your AGI application, communication between Asterisk and
your application will take place over stdin and stdout. More details about this commu-
nication will be covered in “AGI Communication Overview” on page 480. For more
details about invoking AGI() from the dialplan, check the documentation built into
Asterisk:
*CLI> core show application AGI
Pros of process-based AGI
It is the simplest form of AGI to implement.
Cons of process-based AGI
It is the least efficient form of AGI with regard to resource consumption. Systems
with high load should consider FastAGI, discussed in “FastAGI—AGI over
TCP” on page 478, instead.
EAGI
EAGI (Enhanced AGI) is a slight variant on AGI(). It is invoked in the Asterisk dialplan
as EAGI(). The difference is that in addition to the communication on stdin and
stdout, Asterisk also provides a unidirectional stream of audio coming from the channel
on file descriptor 3. For more details on how to invoke EAGI() from the Asterisk dia-
lplan, check the documentation built into Asterisk:
*CLI> core show application EAGI
AGI Variants | 477