login | register
Mon 12 of May, 2008 [00:38 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.
 
Google Ads
Shoutbox
  • Nick Barnes, Fri 09 of May, 2008 [11:36 UTC]: Christopher - yesterday I tried an Asterisk install on a CentOS 5.1 box with stock GUI and it all worked fine. Sorry I can't help.
  • aero, Fri 09 of May, 2008 [08:20 UTC]: can someone help me out on this, i tried to play some sound files on my asterisk box and this is the error message i got. WARNING[4429]: format_wav.c:169 check_header: Unexpected freqency 22050 May 8 11:17:39 WARNING[4433]: codec_gsm.c:194 gsmtolin_fra
  • Christopher Faust, Thu 08 of May, 2008 [14:15 UTC]: I beleive that I may have to change something in the xserver configuration. Please advise
  • Christopher Faust, Thu 08 of May, 2008 [14:14 UTC]: Everything was perfect. In the bios I have increased the memory allocated Still receive input not supported on my display.
  • Christopher Faust, Thu 08 of May, 2008 [14:13 UTC]: This would not be my main box. I am doing some testing to see if I can install zaptel and asterisk 1.4 on a full centos 5.1 box with development software Its bizzare, because before I went through the asterisk and zaptel installation everything was perfe
  • Nick Barnes, Thu 08 of May, 2008 [13:44 UTC]: Christopher - I can't see any way in which an Asterisk installation would muck your GUI, but remember that it is advised not to use a GUI on an Asterisk box anyway.
  • Christopher Faust, Wed 07 of May, 2008 [15:28 UTC]: When I try to startx I ge input not supported. Though before installing asterisk I had no video issue to start the GUI
  • Christopher Faust, Wed 07 of May, 2008 [15:26 UTC]: Hi Nick, I got centos 5.1 and asterisk up But now I cannot start startx I have set the depth from 24 to 16 for the video i810 driver for the i845 on my netvista machine but I cannot start GNOME. Please advise
  • Nick Barnes, Wed 07 of May, 2008 [10:01 UTC]: Howard - You'll need to provide a lot more information if you really want help.
  • Nick Barnes, Wed 07 of May, 2008 [10:00 UTC]: Christopher - Search the Wiki and you'll find a page I wrote detailing exactly what you have to do for Asterisk 1.4 + CentOS 5.1.
Server Stats
  • Execution time: 0.40s
  • Memory usage: 2.33MB
  • Database queries: 33
  • GZIP: Disabled
  • Server load: 1.35

Asterisk manager API

The Asterisk Manager API


The Asterisk Manager allows a client program to connect to an Asterisk instance and issue commands or read PBX events over a TCP/IP stream. Integrators will find this particularly useful when trying to track the state of a telephony client inside Asterisk, and directing that client based on custom (and possibly dynamic) rules.

A simple "key: value" line-based protocol is utilized for communication between the connecting client and the Asterisk PBX. Lines are terminated using CRLF. For the sake of discussion below, we will use the term "packet" to describe a set of "key: value" lines that are terminated by an extra carriage return.

New in Asterisk 1.4: AJAM is a new JavaScript-based technology which allows web browsers or other HTTP enabled applications and web pages to directly access the Asterisk Manager Interface (AMI) via HTTP.

Protocol Behavior


The protocol has the following characteristics:

  • Before issuing commands to Asterisk, you must establish a manager session (see below).
  • Packets may be transmitted in either direction at any time after authentication.
  • The first line of a packet will have a key of "Action" when sent from the client, but "Event" or "Response" when sent from Asterisk to the client.
  • The order of lines within a packet is insignificant, so you may use your favorite programming language's native unordered dictionary type to efficiently store a single packet.
  • CRLF is used to delimit each line and a blank line (two CRLF in a row) indicates the end of the command which Asterisk is now expected to process.

Packet Types


The type of a packet is determined by the existence of one of the following keys:

  • Action: A packet sent by the connected client to Asterisk, requesting a particular Action be performed. There are a finite (but extendable) set of actions available to the client, determined by the modules presently loaded in the Asterisk engine. Only one action may be outstanding at a time. The Action packet contains the name of the operation to be performed as well as all required parameters.
  • Response: the response sent by Asterisk to the last action sent by the client.
  • Event: data pertaining to an event generated from within the Asterisk core or an extension module.

Generally the client sends Action packets to the Asterisk server, the Asterisk server perfoms the requested operation and returns the result (often only success or failure) in a Response packet. As there is no guarantee regarding the order of Response packets the client usually includes an ActionID parameter in every Action packet that is sent back by Asterisk in the corresponding Response packet. That way the client can easily match Action and Response packets while sending Actions at any desired rate without having to wait for outstanding Response packets before sending the next action.

Event packets are used in two different contexts: On the one hand they inform clients about state changes in Asterisk (like new channels being created and hung up or agents being logged in and out) on the other hand they are used to transport the response payload for actions that return a list of data (event generating actions). When a client sends an event generating action Asterisk sends a Response packed indicating success and containing a "Response: Follows" line. Then it sends zero or more events that contain the actual payload and finally an action complete event indicating that all data has been sent. The events sent in response to an event generating action and the action complete event contain the ActionID of the Action packet that triggered them, so you can easily match them the same way as Response packets. An example of an event generating action is the Status action that triggers Status events for each active channel. When all Status events have been sent a terminating a StatusComplete event is sent.

Opening a Manager Session and Authenticating as a User


In order to access the Asterisk Manager functionality a user needs to establish a session by opening a TCP/IP connection to the listening port (usually 5038) of the Asterisk instance and logging into the manager using the 'Login' action. This requires a previously established user account on the Asterisk server. User accounts are configured in /etc/asterisk/manager.conf. A user account consists of a set of permitted IP hosts, an authentication secret (password), and a list of granted permissions.

There is a finite set of permissions, each may be granted with either "read", "write", or "read/write" granularity. If a client is granted the ability to read a given class, Asterisk will send it events of that class. If a client is granted the ability to write a given class, it may send actions of that class.

To login and authenticate to the manager, you must send a "Login" action, with your user name and secret (password) as parameters. Here is an example:

  Action: login
  Username: admin
  Secret: god


If you do not need to subscribe to events being generated by Asterisk, you may also include the "Events: off" parameter, which will prevent event packets being sent to your connection. This is the equivalent of calling the "Events" action. Example:

  Action: login
  Username: admin
  Secret: god
  Events: off



Action Packets


When sending Asterisk an action, extra keys may be provided to further direct execution, for example, you may wish to specify a number to call, a channel to disconnect. Additionally, if your action causes Asterisk to execute an entry in the dialplan, you may wish to pass variables to the dialplan (available as of bug 1268). This is done exactly the same way you would send keys.

To send Asterisk an action, follow this simple format:

   Action: <action type><CRLF>
   <Key 1>: <Value 1><CRLF>
   <Key 2>: <Value 2><CRLF>
   ...
   Variable: <Variable 1>=<Value 1><CRLF>
   Variable: <Variable 2>=<Value 2><CRLF>
   ...
   <CRLF>



Manager Actions


Output from the CLI command show manager commands:
(For Asterisk 1.4 and greater, use manager show commands)



(New?) in Asterisk 1.2.1 (was "CVS HEAD") (Taken from the output of CLI command show manager commands):

  • AgentCallbackLogin: Sets an agent as logged in by callback (Privilege: agent,all)
  • AgentLogoff: Sets an agent as no longer logged in (Privilege: agent,all)
  • Agents: Lists agents and their status (Privilege: agent,all)
  • DBGet: Get DB Entry (Privilege: system,all)
  • DBPut: Put DB Entry (Privilege: system,all)
  • QueuePause: Makes a queue member temporarily unavailable (Privilege: agent,all)
  • SIPshowPeer: Show SIP peer (text format) (Privilege: system,all)

New in Asterisk 1.4.0
  • PlayDTMF: Play DTMF signal on a specific channel. (Privilege: call,all)

New in Asterisk 1.4.0
  • UpdateConfig: Updates a configuration file, used mainly by AJAM/Asterisk-gui. (Privilege: config,all)
  • GetConfig: Display a configuration file, used mainly by AJAM/Asterisk-gui. (Privilege: config,all)



Asterisk Events

These are listed on a separate page: asterisk manager events.


Manager Examples

These are listed on a separate page also: Asterisk manager Examples.

Caveat


We're sorry, but if you do a show applications on the console, you will see the command to view connected managers is show manager connect, but the correct command is show manager connected. Please make a note of it.

See also


Created by oej, Last modification by Doug Bromley on Tue 01 of Apr, 2008 [19:40 UTC]

Comments Filter

How to Set Hangup Time?

by Malik Asif Joyia on Tuesday 22 of January, 2008 [11:48:56 UTC]
How to Setup the hangup time for a call in Originate?
Please help
ASIF

How to distinguish the CallerID??

by Rena on Tuesday 04 of December, 2007 [06:04:05 UTC]
Hello,
   There are many "Events" from the AMI when dial in. And If I want to know which number is the callerID, What can I do for this? and How can I select the right "Events" for the judgement?

by simi on Monday 22 of October, 2007 [10:26:53 UTC]
hi ,

i want to add more information in cdr. can anybody help me??? i just want an idea as to what should i do... a direction is needed.

how to get db value from api manager

by thrall on Tuesday 09 of October, 2007 [08:54:09 UTC]
Hi All,

Anyone knows how to get db value from api manager I'm using asterisk 1.4.11. I've been using dbgetresponse to get the value from db since 1.2 unfortunately it's been removed in 1.4. Any other way to get the same result? Asterisk developer may have solution to this as newer version supposed to be functioning better rather than lacking functionalities :(

Thanks in advance!

filter the event sent by the manger

by Gommidh on Monday 21 of May, 2007 [21:32:13 UTC]
hi,

did some one know a way to tell the manger send only some event to the client connected ?
for exemple :

client A recive the event : new channel
client B recive the event : hangup

Re: Ping the server after login

by jesselang on Monday 08 of January, 2007 [21:10:22 UTC]
It should be "Action: Ping\r\n\r\n". "Parameters: None" means that you should not pass any parameters with that action. Hope that helps!

Ping the server after login

by xutom2006 on Monday 30 of October, 2006 [10:28:07 UTC]
I have used the command "sendto(clifd, bufLogin, BUFFER_SIZE, 0, (struct sockaddr_in *)&servaddr, socklen))" in C program and the bufLogin is :"Action: login\r\nUsername: admin\r\nSecret: admin\r\n\r\n" , and the debug message(is "Response: Success
Message: Authentication accepted") of the remote asterisk server shows that i have logined on successfully. Now i again run another command "sendto(clifd, bufPing, strlen(bufPing), 0, (struct sockaddr_in *)&servaddr, socklen))" and the bufPing is "Action: Ping\r\nParameters: None\r\n\r\n" , this time i get the result :Response: Error
Message: Missing action in request" ,and my /var/log/asterisk/full contains the following message:"Oct 30 03:21:43 DEBUG2627 manager.c: Manager received command '' ",the ping command is NULL ? Why? Can someone help me?

thanks in advance... xutom

Ping the server after login

by xutom2006 on Monday 30 of October, 2006 [10:24:41 UTC]
I have used the command "sendto(clifd, bufLogin, BUFFER_SIZE, 0, (struct sockaddr_in *)&servaddr, socklen))" in C program and the bufLogin is :"Action: login\r\nUsername: admin\r\nSecret: admin\r\n\r\n" , and the debug message(is "Response: Success
Message: Authentication accepted") of the remote asterisk server shows that i have logined on successfully. Now i again run another command "sendto(clifd, bufPing, strlen(bufPing), 0, (struct sockaddr_in *)&servaddr, socklen))" and the bufPing is "Action: Ping\r\nParameters: None\r\n\r\n" , this time i get the result :Response: Error
Message: Missing action in request" ,and my /var/log/asterisk/full contains the following message:"Oct 30 03:21:43 DEBUG2627 manager.c: Manager received command '' ",the ping command is NULL ? Why? Can someone help me?

thanks in advance... xutom

Ping the server after login

by xutom2006 on Monday 30 of October, 2006 [08:29:00 UTC]
I have used the command "sendto(clifd, bufLogin, BUFFER_SIZE, 0, (struct sockaddr_in *)&servaddr, socklen))" in C program and the bufLogin is :"Action: login\r\nUsername: admin\r\nSecret: admin\r\n\r\n" , and the debug message(is "Response: Success
Message: Authentication accepted") of the remote asterisk server shows that i have logined on successfully. Now i again run another command "sendto(clifd, bufPing, strlen(bufPing), 0, (struct sockaddr_in *)&servaddr, socklen))" and the bufPing is "Action: Ping\r\nParameters: None\r\n\r\n" , this time i get the result :Response: Error
Message: Missing action in request" ,and my /var/log/asterisk/full contains the following message:"Oct 30 03:21:43 DEBUG2627 manager.c: Manager received command '' ",the ping command is NULL ? Why? Can someone help me?

thanks in advance... xutom

Re: DBDel?

by Andy on Wednesday 28 of June, 2006 [13:42:19 UTC]
Until DBDel is implemented, you can do the following:

Action: command\r\n
Command: database del Family Key\r\n\r\n

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2008 VOIP-Info.org LLC

Powered by bitweaver