📜 ⬆️ ⬇️

Asterisk Managment Interface (AMI), Part 2

In continuation of the first part of the description of the operation of the open-source PBX interface Asterisk I publish the second part of the other day. This part provides some examples of using this interface for interacting with PBX, starting from connection and authorization, to calling and editing configuration files.

The full version of the article was written and will be corrected here: asteriskpbx.ru/wiki/manager-interface-doc

AMI connection


To connect to AMI, you can use the telnet program. This is how the greeting system looks like:

$ telnet 127.0.0.1 5038
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Asterisk Call Manager/1.1

')
Next, type:

Action: login
Username: admin
Secret: passwd1234


two times Enter, which is equivalent to entering CRLF After, should see the following response (Response package):

Response: Success
Message: Authentication accepted

That tells us that we successfully logged into the AMI interface. During the successful entry into AMI, in the console of Asterisk we will see (in 1.4):

asterisk*CLI>
== Parsing '/etc/asterisk/manager.conf': Found
== Manager 'admin' logged on from 127.0.0.1

1.6 eliminates the need to read a configuration from a disk each time you connect to AMI. They are read once at the start of the program and can be re-read upon reboot (the commands are given above).

You can see all users currently connected to the AMI interface from the Asterisk console:

*CLI> manager show connected

Changing the password and executing the 'manager reload' command does not affect the permissions for already established AMI sessions. This means that if the password or access rights are changed in the file, these changes will not affect the clients already working with the server.

If you do not need events generated by Asterisk (there may be a lot of them, which make it difficult to read Asterisk responses in the console), you can also include another entry in the parameters passed during the authentication procedure.

Events: off

This entry prevents the sending of Event packets by the server within the established connection.

To terminate an AMI connection session, you need to run:

Action: logoff

After that we will see the session on the telnet screen:

Response: Goodbye
Message: Thanks for all the fish.

During the completion of the AMI session, we can see the following in the Asterisk console:

asterisk*CLI>
== Manager 'admin' logged off from 127.0.0.1

Note Naturally, the AMI interface is not intended for the administrator to manually connect to the Asterisk server using a telnet client and the like. Here, this example is shown solely as a demonstration of the possibilities and visibility of the work of exchanging Action, Event and Response packets. However, this approach can be useful in learning and debugging the actions of a team.

Note You can see all the commands related to the Asterisk AMI Management CLI management interface by typing in the console:

asterisk *CLI> help manager

AMI authorization passwords



It is important to understand that the passwords transmitted when connecting to the AMI interface are transmitted in clear text. This can be a threat to the operation of the Asterisk service. To hide the transmitted password, use the md5 algorithm. Using the md5 algorithm in no way removes the security requirements described above. If you still use a remote connection even on a private network, it is recommended to use the request / response and the md5 algorithm, the principle of which is very similar to the similar HTTP and SIP authentication. To do this, first call the action Challenge (Request), which will provide you with a request token:
Action: Challenge
AuthType: md5

Response: Success
Challenge: 84041345


After that, you can take the token of the received request and add the unencrypted password at the end and calculate the checksum of the resulting string using the md5 algorithm. The result can be used for registration without the need to transfer the secret in clear text (plain text). It will look like this:

Action: login
AuthType: MD5
Username: admin
Key: qwf32r23p98yvdspa9h4o4woaewv7

where Key is the resulting amount.

Note The md5 input algorithm accepts any length of characters and outputs a 128-bit fingerprint (finger-print) or message profile (message digest) that was input to the algorithm. It is hypothesized that two messages that have the same message profile or are generated by any message have a specific message profile.

Message digest is a short fixed-length digital string, formed from a longer message using a special algorithm. The md5 algorithm is assigned to a digital signature (digital signature) of applications where large files must be “compressed” in a secure way before they are encrypted with a public or private key using a public key cryptosystem, such as RSA. Digital signature is a digital signature that is a unique electronic identifier that verifies the message with the sender's authenticity and ensures that the document has not been changed since it was signed.

Action Packages


At a time when Asterisk sends Action packets, it is necessary to provide additional keys for proper execution, for example, you will want to determine the call number and so on. Moreover, you may want to log in to the Asterisk numbering plan and pass some parameters to the channel variables. In this case, the key transfer process will look like this:

Action: <key 1>: <value 1>
<key 2>: <value 2>
.......

, AMI ( Manager' ):

Action: Originate
Channel: SIP/2401
Context: incoming
Exten: 2401
Priority: 1
Callerid: 2401
Variable: ANSWER=1
Variable: _ACC=2

, SIP 2401 . Enter, SIP-. :

Action: Originate
Channel: SIP/2401
Context: incoming
Exten: 2401
Priority: 1
Callerid: 2401
Variable: ANSWER=1
Variable: _ACC=2

Event: Newchannel
Privilege: call,all
Channel: SIP/2401-09a1f418
State: Down
CallerIDNum: CallerIDName: Uniqueid: 1237301090.1

Event: Newcallerid
Privilege: call,all
Channel: SIP/2401-09a1f418
CallerID: 2401
CallerIDName: Uniqueid: 1237301090.1
CID-CallingPres: 0 (Presentation Allowed, Not Screened)

Event: Newstate
Privilege: call,all
Channel: SIP/2401-09a1f418
State: Ringing
CallerID: 2401
CallerIDName: Uniqueid: 1237301090.1

Event: Hangup
Privilege: call,all
Channel: SIP/2401-09a1f418
Uniqueid: 1237301090.1
Cause: 19
Cause-txt: User alerting, no answer

, , CLI ;

asterisk*CLI> manager show eventq

:

Usecount: 1
Category: 2
Event:
Event: Hangup
Privilege: call,all
Channel: SIP/2401-09a1f418
Uniqueid: 1237301603.2
Cause: 21
Cause-txt:

, Originate, AMI. AMI, CLI :

asterisk *CLI> manager show command [_]


read write

read write manager.conf AMI. , AMI manager.conf read write «command», , — privilege:command. , , AMI , :

asterisk*CLI> manager show command Command
Action: Command
Synopsis: Execute Asterisk CLI Command
Privilege: command,all
Description: Run a CLI command.
Variables: (Names marked with * are required)
*Command: Asterisk CLI command to run
ActionID: Optional Action id for message matching.

(Synopsis) , . Privilege , manager.conf , AMI. Variables , . — *Command, ( ), ActionID — .

, manager.conf AMI — (access list). , (events) (actions), . read/write. Read , AMI.

Write , AMI , . read/write, :

system — , , SIP ; call — , , ; log — Logging information, , ; verbose - Verbose information, , ; command — CLI ; agent — , (queue); user — , , UserEvent. , , AGI, AMI ; config - ; dtmf - DTMF ( ); reporting - ; cdr - cdr_manager ( , ); dialplan - NewExten VarSet ( ); originate - ( ).
, AMI . , 1.4 1.6 AMI , - (flow control) , . AMI , AMI .
AMI. ActionID. AMI ¶

AMI , . :

asterisk *CLI> manager show command GetConfig


sip.conf :

Action: GetConfig
Filename: sip.conf
ActionID: 435430239485234

:

Response: Success
ActionID: 435430239485234
Category-000000: general
Line-000000-000000: context=incoming
Line-000000-000001: language=ru
Line-000000-000002: allowguest=yes
Line-000000-000003: bindport=5060
Line-000000-000004: bindaddr=0.0.0.0
Line-000000-000005: dtmfmode=info
Line-000000-000006: disallow=all
Line-000000-000007: allow=alaw
Line-000000-000008: allow=ulaw
Line-000000-000009: allow=gsm
Line-000000-000010: nat=never
Line-000000-000011: canreinvite=no
Category-000001: 2401
Line-000001-000000: type=friend
Line-000001-000001: host=dynamic
Line-000001-000002: username=2401
Line-000001-000003: secret=2401
Line-000001-000004: callerid=2401
Line-000001-000005: context=incoming


Action , , Response ActionID. AMI, ActionID «» , , , (Action-), , Response-. , Response- , AMI. , Action-, Action Response. , AMI .

sip.conf, AMI :

Action: Command
Command: sip reload
ActionID: 230432984582

AMI:

Response: Follows
Privilege: Command
ActionID: 230432984582
--END COMMAND--

Event: ChannelReload
Privilege: system,all
Channel: SIP
ReloadReason: CLIRELOAD (Channel module reload by CLI command)
Registry_Count: 0
Peer_Count: 2
User_Count: 2

AMI . UpdateConfig. , 2402 sip.conf. UpdateConfig :

asterisk*CLI> manager show command UpdateConfig
Action: UpdateConfig
Synopsis: Update basic configuration
Privilege: config,all
Description: A 'UpdateConfig' action will modify, create, or delete
configuration elements in Asterisk configuration files.
Variables (X's represent 6 digit number beginning with 000000):
SrcFilename: Configuration filename to read(eg foo.conf)
DstFilename: Configuration filename to write(eg foo.conf)
Reload: Whether or not a reload should take place (or name of specific module)
Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)
Cat-XXXXXX: Category to operate on
Var-XXXXXX: Variable to work on
Value-XXXXXX: Value to work on
Match-XXXXXX: Extra match required to match line

, . , :

SrcFilename: UpdateConfig, ; DstFilename: , ; Reload: , , , , ; Action-XXXXX: , , . : NewCat, RenameCat, DelCat, Update, Delete Append; Cat-XXXXX: , ; Var-XXXXX: , ; Value-XXXXX: , ; Match-XXXXX: , , , ; ActionID: , , .
: config, all.

Action: <key 1>: <value 1>
<key 2>: <value 2>
.......

, AMI ( Manager' ):

Action: Originate
Channel: SIP/2401
Context: incoming
Exten: 2401
Priority: 1
Callerid: 2401
Variable: ANSWER=1
Variable: _ACC=2

, SIP 2401 . Enter, SIP-. :

Action: Originate
Channel: SIP/2401
Context: incoming
Exten: 2401
Priority: 1
Callerid: 2401
Variable: ANSWER=1
Variable: _ACC=2

Event: Newchannel
Privilege: call,all
Channel: SIP/2401-09a1f418
State: Down
CallerIDNum: CallerIDName: Uniqueid: 1237301090.1

Event: Newcallerid
Privilege: call,all
Channel: SIP/2401-09a1f418
CallerID: 2401
CallerIDName: Uniqueid: 1237301090.1
CID-CallingPres: 0 (Presentation Allowed, Not Screened)

Event: Newstate
Privilege: call,all
Channel: SIP/2401-09a1f418
State: Ringing
CallerID: 2401
CallerIDName: Uniqueid: 1237301090.1

Event: Hangup
Privilege: call,all
Channel: SIP/2401-09a1f418
Uniqueid: 1237301090.1
Cause: 19
Cause-txt: User alerting, no answer

, , CLI ;

asterisk*CLI> manager show eventq

:

Usecount: 1
Category: 2
Event:
Event: Hangup
Privilege: call,all
Channel: SIP/2401-09a1f418
Uniqueid: 1237301603.2
Cause: 21
Cause-txt:

, Originate, AMI. AMI, CLI :

asterisk *CLI> manager show command [_]


read write

read write manager.conf AMI. , AMI manager.conf read write «command», , — privilege:command. , , AMI , :

asterisk*CLI> manager show command Command
Action: Command
Synopsis: Execute Asterisk CLI Command
Privilege: command,all
Description: Run a CLI command.
Variables: (Names marked with * are required)
*Command: Asterisk CLI command to run
ActionID: Optional Action id for message matching.

(Synopsis) , . Privilege , manager.conf , AMI. Variables , . — *Command, ( ), ActionID — .

, manager.conf AMI — (access list). , (events) (actions), . read/write. Read , AMI.

Write , AMI , . read/write, :

system — , , SIP ; call — , , ; log — Logging information, , ; verbose - Verbose information, , ; command — CLI ; agent — , (queue); user — , , UserEvent. , , AGI, AMI ; config - ; dtmf - DTMF ( ); reporting - ; cdr - cdr_manager ( , ); dialplan - NewExten VarSet ( ); originate - ( ).
, AMI . , 1.4 1.6 AMI , - (flow control) , . AMI , AMI .
AMI. ActionID. AMI ¶

AMI , . :

asterisk *CLI> manager show command GetConfig


sip.conf :

Action: GetConfig
Filename: sip.conf
ActionID: 435430239485234

:

Response: Success
ActionID: 435430239485234
Category-000000: general
Line-000000-000000: context=incoming
Line-000000-000001: language=ru
Line-000000-000002: allowguest=yes
Line-000000-000003: bindport=5060
Line-000000-000004: bindaddr=0.0.0.0
Line-000000-000005: dtmfmode=info
Line-000000-000006: disallow=all
Line-000000-000007: allow=alaw
Line-000000-000008: allow=ulaw
Line-000000-000009: allow=gsm
Line-000000-000010: nat=never
Line-000000-000011: canreinvite=no
Category-000001: 2401
Line-000001-000000: type=friend
Line-000001-000001: host=dynamic
Line-000001-000002: username=2401
Line-000001-000003: secret=2401
Line-000001-000004: callerid=2401
Line-000001-000005: context=incoming


Action , , Response ActionID. AMI, ActionID «» , , , (Action-), , Response-. , Response- , AMI. , Action-, Action Response. , AMI .

sip.conf, AMI :

Action: Command
Command: sip reload
ActionID: 230432984582

AMI:

Response: Follows
Privilege: Command
ActionID: 230432984582
--END COMMAND--

Event: ChannelReload
Privilege: system,all
Channel: SIP
ReloadReason: CLIRELOAD (Channel module reload by CLI command)
Registry_Count: 0
Peer_Count: 2
User_Count: 2

AMI . UpdateConfig. , 2402 sip.conf. UpdateConfig :

asterisk*CLI> manager show command UpdateConfig
Action: UpdateConfig
Synopsis: Update basic configuration
Privilege: config,all
Description: A 'UpdateConfig' action will modify, create, or delete
configuration elements in Asterisk configuration files.
Variables (X's represent 6 digit number beginning with 000000):
SrcFilename: Configuration filename to read(eg foo.conf)
DstFilename: Configuration filename to write(eg foo.conf)
Reload: Whether or not a reload should take place (or name of specific module)
Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)
Cat-XXXXXX: Category to operate on
Var-XXXXXX: Variable to work on
Value-XXXXXX: Value to work on
Match-XXXXXX: Extra match required to match line

, . , :

SrcFilename: UpdateConfig, ; DstFilename: , ; Reload: , , , , ; Action-XXXXX: , , . : NewCat, RenameCat, DelCat, Update, Delete Append; Cat-XXXXX: , ; Var-XXXXX: , ; Value-XXXXX: , ; Match-XXXXX: , , , ; ActionID: , , .
: config, all.

Action: <key 1>: <value 1>
<key 2>: <value 2>
.......

, AMI ( Manager' ):

Action: Originate
Channel: SIP/2401
Context: incoming
Exten: 2401
Priority: 1
Callerid: 2401
Variable: ANSWER=1
Variable: _ACC=2

, SIP 2401 . Enter, SIP-. :

Action: Originate
Channel: SIP/2401
Context: incoming
Exten: 2401
Priority: 1
Callerid: 2401
Variable: ANSWER=1
Variable: _ACC=2

Event: Newchannel
Privilege: call,all
Channel: SIP/2401-09a1f418
State: Down
CallerIDNum: CallerIDName: Uniqueid: 1237301090.1

Event: Newcallerid
Privilege: call,all
Channel: SIP/2401-09a1f418
CallerID: 2401
CallerIDName: Uniqueid: 1237301090.1
CID-CallingPres: 0 (Presentation Allowed, Not Screened)

Event: Newstate
Privilege: call,all
Channel: SIP/2401-09a1f418
State: Ringing
CallerID: 2401
CallerIDName: Uniqueid: 1237301090.1

Event: Hangup
Privilege: call,all
Channel: SIP/2401-09a1f418
Uniqueid: 1237301090.1
Cause: 19
Cause-txt: User alerting, no answer

, , CLI ;

asterisk*CLI> manager show eventq

:

Usecount: 1
Category: 2
Event:
Event: Hangup
Privilege: call,all
Channel: SIP/2401-09a1f418
Uniqueid: 1237301603.2
Cause: 21
Cause-txt:

, Originate, AMI. AMI, CLI :

asterisk *CLI> manager show command [_]


read write

read write manager.conf AMI. , AMI manager.conf read write «command», , — privilege:command. , , AMI , :

asterisk*CLI> manager show command Command
Action: Command
Synopsis: Execute Asterisk CLI Command
Privilege: command,all
Description: Run a CLI command.
Variables: (Names marked with * are required)
*Command: Asterisk CLI command to run
ActionID: Optional Action id for message matching.

(Synopsis) , . Privilege , manager.conf , AMI. Variables , . — *Command, ( ), ActionID — .

, manager.conf AMI — (access list). , (events) (actions), . read/write. Read , AMI.

Write , AMI , . read/write, :

system — , , SIP ; call — , , ; log — Logging information, , ; verbose - Verbose information, , ; command — CLI ; agent — , (queue); user — , , UserEvent. , , AGI, AMI ; config - ; dtmf - DTMF ( ); reporting - ; cdr - cdr_manager ( , ); dialplan - NewExten VarSet ( ); originate - ( ).
, AMI . , 1.4 1.6 AMI , - (flow control) , . AMI , AMI .
AMI. ActionID. AMI ¶

AMI , . :

asterisk *CLI> manager show command GetConfig


sip.conf :

Action: GetConfig
Filename: sip.conf
ActionID: 435430239485234

:

Response: Success
ActionID: 435430239485234
Category-000000: general
Line-000000-000000: context=incoming
Line-000000-000001: language=ru
Line-000000-000002: allowguest=yes
Line-000000-000003: bindport=5060
Line-000000-000004: bindaddr=0.0.0.0
Line-000000-000005: dtmfmode=info
Line-000000-000006: disallow=all
Line-000000-000007: allow=alaw
Line-000000-000008: allow=ulaw
Line-000000-000009: allow=gsm
Line-000000-000010: nat=never
Line-000000-000011: canreinvite=no
Category-000001: 2401
Line-000001-000000: type=friend
Line-000001-000001: host=dynamic
Line-000001-000002: username=2401
Line-000001-000003: secret=2401
Line-000001-000004: callerid=2401
Line-000001-000005: context=incoming


Action , , Response ActionID. AMI, ActionID «» , , , (Action-), , Response-. , Response- , AMI. , Action-, Action Response. , AMI .

sip.conf, AMI :

Action: Command
Command: sip reload
ActionID: 230432984582

AMI:

Response: Follows
Privilege: Command
ActionID: 230432984582
--END COMMAND--

Event: ChannelReload
Privilege: system,all
Channel: SIP
ReloadReason: CLIRELOAD (Channel module reload by CLI command)
Registry_Count: 0
Peer_Count: 2
User_Count: 2

AMI . UpdateConfig. , 2402 sip.conf. UpdateConfig :

asterisk*CLI> manager show command UpdateConfig
Action: UpdateConfig
Synopsis: Update basic configuration
Privilege: config,all
Description: A 'UpdateConfig' action will modify, create, or delete
configuration elements in Asterisk configuration files.
Variables (X's represent 6 digit number beginning with 000000):
SrcFilename: Configuration filename to read(eg foo.conf)
DstFilename: Configuration filename to write(eg foo.conf)
Reload: Whether or not a reload should take place (or name of specific module)
Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)
Cat-XXXXXX: Category to operate on
Var-XXXXXX: Variable to work on
Value-XXXXXX: Value to work on
Match-XXXXXX: Extra match required to match line

, . , :

SrcFilename: UpdateConfig, ; DstFilename: , ; Reload: , , , , ; Action-XXXXX: , , . : NewCat, RenameCat, DelCat, Update, Delete Append; Cat-XXXXX: , ; Var-XXXXX: , ; Value-XXXXX: , ; Match-XXXXX: , , , ; ActionID: , , .
: config, all.
Action: <key 1>: <value 1>
<key 2>: <value 2>
.......

, AMI ( Manager' ):

Action: Originate
Channel: SIP/2401
Context: incoming
Exten: 2401
Priority: 1
Callerid: 2401
Variable: ANSWER=1
Variable: _ACC=2

, SIP 2401 . Enter, SIP-. :

Action: Originate
Channel: SIP/2401
Context: incoming
Exten: 2401
Priority: 1
Callerid: 2401
Variable: ANSWER=1
Variable: _ACC=2

Event: Newchannel
Privilege: call,all
Channel: SIP/2401-09a1f418
State: Down
CallerIDNum: CallerIDName: Uniqueid: 1237301090.1

Event: Newcallerid
Privilege: call,all
Channel: SIP/2401-09a1f418
CallerID: 2401
CallerIDName: Uniqueid: 1237301090.1
CID-CallingPres: 0 (Presentation Allowed, Not Screened)

Event: Newstate
Privilege: call,all
Channel: SIP/2401-09a1f418
State: Ringing
CallerID: 2401
CallerIDName: Uniqueid: 1237301090.1

Event: Hangup
Privilege: call,all
Channel: SIP/2401-09a1f418
Uniqueid: 1237301090.1
Cause: 19
Cause-txt: User alerting, no answer

, , CLI ;

asterisk*CLI> manager show eventq

:

Usecount: 1
Category: 2
Event:
Event: Hangup
Privilege: call,all
Channel: SIP/2401-09a1f418
Uniqueid: 1237301603.2
Cause: 21
Cause-txt:

, Originate, AMI. AMI, CLI :

asterisk *CLI> manager show command [_]


read write

read write manager.conf AMI. , AMI manager.conf read write «command», , — privilege:command. , , AMI , :

asterisk*CLI> manager show command Command
Action: Command
Synopsis: Execute Asterisk CLI Command
Privilege: command,all
Description: Run a CLI command.
Variables: (Names marked with * are required)
*Command: Asterisk CLI command to run
ActionID: Optional Action id for message matching.

(Synopsis) , . Privilege , manager.conf , AMI. Variables , . — *Command, ( ), ActionID — .

, manager.conf AMI — (access list). , (events) (actions), . read/write. Read , AMI.

Write , AMI , . read/write, :

system — , , SIP ; call — , , ; log — Logging information, , ; verbose - Verbose information, , ; command — CLI ; agent — , (queue); user — , , UserEvent. , , AGI, AMI ; config - ; dtmf - DTMF ( ); reporting - ; cdr - cdr_manager ( , ); dialplan - NewExten VarSet ( ); originate - ( ).
, AMI . , 1.4 1.6 AMI , - (flow control) , . AMI , AMI .
AMI. ActionID. AMI ¶

AMI , . :

asterisk *CLI> manager show command GetConfig


sip.conf :

Action: GetConfig
Filename: sip.conf
ActionID: 435430239485234

:

Response: Success
ActionID: 435430239485234
Category-000000: general
Line-000000-000000: context=incoming
Line-000000-000001: language=ru
Line-000000-000002: allowguest=yes
Line-000000-000003: bindport=5060
Line-000000-000004: bindaddr=0.0.0.0
Line-000000-000005: dtmfmode=info
Line-000000-000006: disallow=all
Line-000000-000007: allow=alaw
Line-000000-000008: allow=ulaw
Line-000000-000009: allow=gsm
Line-000000-000010: nat=never
Line-000000-000011: canreinvite=no
Category-000001: 2401
Line-000001-000000: type=friend
Line-000001-000001: host=dynamic
Line-000001-000002: username=2401
Line-000001-000003: secret=2401
Line-000001-000004: callerid=2401
Line-000001-000005: context=incoming


Action , , Response ActionID. AMI, ActionID «» , , , (Action-), , Response-. , Response- , AMI. , Action-, Action Response. , AMI .

sip.conf, AMI :

Action: Command
Command: sip reload
ActionID: 230432984582

AMI:

Response: Follows
Privilege: Command
ActionID: 230432984582
--END COMMAND--

Event: ChannelReload
Privilege: system,all
Channel: SIP
ReloadReason: CLIRELOAD (Channel module reload by CLI command)
Registry_Count: 0
Peer_Count: 2
User_Count: 2

AMI . UpdateConfig. , 2402 sip.conf. UpdateConfig :

asterisk*CLI> manager show command UpdateConfig
Action: UpdateConfig
Synopsis: Update basic configuration
Privilege: config,all
Description: A 'UpdateConfig' action will modify, create, or delete
configuration elements in Asterisk configuration files.
Variables (X's represent 6 digit number beginning with 000000):
SrcFilename: Configuration filename to read(eg foo.conf)
DstFilename: Configuration filename to write(eg foo.conf)
Reload: Whether or not a reload should take place (or name of specific module)
Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)
Cat-XXXXXX: Category to operate on
Var-XXXXXX: Variable to work on
Value-XXXXXX: Value to work on
Match-XXXXXX: Extra match required to match line

, . , :

SrcFilename: UpdateConfig, ; DstFilename: , ; Reload: , , , , ; Action-XXXXX: , , . : NewCat, RenameCat, DelCat, Update, Delete Append; Cat-XXXXX: , ; Var-XXXXX: , ; Value-XXXXX: , ; Match-XXXXX: , , , ; ActionID: , , .
: config, all.
Action: <key 1>: <value 1>
<key 2>: <value 2>
.......

, AMI ( Manager' ):

Action: Originate
Channel: SIP/2401
Context: incoming
Exten: 2401
Priority: 1
Callerid: 2401
Variable: ANSWER=1
Variable: _ACC=2

, SIP 2401 . Enter, SIP-. :

Action: Originate
Channel: SIP/2401
Context: incoming
Exten: 2401
Priority: 1
Callerid: 2401
Variable: ANSWER=1
Variable: _ACC=2

Event: Newchannel
Privilege: call,all
Channel: SIP/2401-09a1f418
State: Down
CallerIDNum: CallerIDName: Uniqueid: 1237301090.1

Event: Newcallerid
Privilege: call,all
Channel: SIP/2401-09a1f418
CallerID: 2401
CallerIDName: Uniqueid: 1237301090.1
CID-CallingPres: 0 (Presentation Allowed, Not Screened)

Event: Newstate
Privilege: call,all
Channel: SIP/2401-09a1f418
State: Ringing
CallerID: 2401
CallerIDName: Uniqueid: 1237301090.1

Event: Hangup
Privilege: call,all
Channel: SIP/2401-09a1f418
Uniqueid: 1237301090.1
Cause: 19
Cause-txt: User alerting, no answer

, , CLI ;

asterisk*CLI> manager show eventq

:

Usecount: 1
Category: 2
Event:
Event: Hangup
Privilege: call,all
Channel: SIP/2401-09a1f418
Uniqueid: 1237301603.2
Cause: 21
Cause-txt:

, Originate, AMI. AMI, CLI :

asterisk *CLI> manager show command [_]


read write

read write manager.conf AMI. , AMI manager.conf read write «command», , — privilege:command. , , AMI , :

asterisk*CLI> manager show command Command
Action: Command
Synopsis: Execute Asterisk CLI Command
Privilege: command,all
Description: Run a CLI command.
Variables: (Names marked with * are required)
*Command: Asterisk CLI command to run
ActionID: Optional Action id for message matching.

(Synopsis) , . Privilege , manager.conf , AMI. Variables , . — *Command, ( ), ActionID — .

, manager.conf AMI — (access list). , (events) (actions), . read/write. Read , AMI.

Write , AMI , . read/write, :

system — , , SIP ; call — , , ; log — Logging information, , ; verbose - Verbose information, , ; command — CLI ; agent — , (queue); user — , , UserEvent. , , AGI, AMI ; config - ; dtmf - DTMF ( ); reporting - ; cdr - cdr_manager ( , ); dialplan - NewExten VarSet ( ); originate - ( ).
, AMI . , 1.4 1.6 AMI , - (flow control) , . AMI , AMI .
AMI. ActionID. AMI ¶

AMI , . :

asterisk *CLI> manager show command GetConfig


sip.conf :

Action: GetConfig
Filename: sip.conf
ActionID: 435430239485234

:

Response: Success
ActionID: 435430239485234
Category-000000: general
Line-000000-000000: context=incoming
Line-000000-000001: language=ru
Line-000000-000002: allowguest=yes
Line-000000-000003: bindport=5060
Line-000000-000004: bindaddr=0.0.0.0
Line-000000-000005: dtmfmode=info
Line-000000-000006: disallow=all
Line-000000-000007: allow=alaw
Line-000000-000008: allow=ulaw
Line-000000-000009: allow=gsm
Line-000000-000010: nat=never
Line-000000-000011: canreinvite=no
Category-000001: 2401
Line-000001-000000: type=friend
Line-000001-000001: host=dynamic
Line-000001-000002: username=2401
Line-000001-000003: secret=2401
Line-000001-000004: callerid=2401
Line-000001-000005: context=incoming


Action , , Response ActionID. AMI, ActionID «» , , , (Action-), , Response-. , Response- , AMI. , Action-, Action Response. , AMI .

sip.conf, AMI :

Action: Command
Command: sip reload
ActionID: 230432984582

AMI:

Response: Follows
Privilege: Command
ActionID: 230432984582
--END COMMAND--

Event: ChannelReload
Privilege: system,all
Channel: SIP
ReloadReason: CLIRELOAD (Channel module reload by CLI command)
Registry_Count: 0
Peer_Count: 2
User_Count: 2

AMI . UpdateConfig. , 2402 sip.conf. UpdateConfig :

asterisk*CLI> manager show command UpdateConfig
Action: UpdateConfig
Synopsis: Update basic configuration
Privilege: config,all
Description: A 'UpdateConfig' action will modify, create, or delete
configuration elements in Asterisk configuration files.
Variables (X's represent 6 digit number beginning with 000000):
SrcFilename: Configuration filename to read(eg foo.conf)
DstFilename: Configuration filename to write(eg foo.conf)
Reload: Whether or not a reload should take place (or name of specific module)
Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)
Cat-XXXXXX: Category to operate on
Var-XXXXXX: Variable to work on
Value-XXXXXX: Value to work on
Match-XXXXXX: Extra match required to match line

, . , :

SrcFilename: UpdateConfig, ; DstFilename: , ; Reload: , , , , ; Action-XXXXX: , , . : NewCat, RenameCat, DelCat, Update, Delete Append; Cat-XXXXX: , ; Var-XXXXX: , ; Value-XXXXX: , ; Match-XXXXX: , , , ; ActionID: , , .
: config, all.

Source: https://habr.com/ru/post/64243/


All Articles