http://blog.csdn.net/niino/article/details/5748805php
要激活AMI,須要在/etc/asterisk/manager.conf中,[general]塊下設置enabled=yeshtml
而後添加用戶,好比linux
[admin]git
secret = adminweb
deny = 0.0.0.0/0.0.0.0數據庫
permit = 127.0.0.1/255.255.255.0ubuntu
read = all,system,call,log,verbose,command,agent,user,config瀏覽器
write = all,system,call,log,verbose,command,agent,user,config服務器
重啓asterisk,用telnet鏈接到AMI網絡
如今,能夠輸入命令來登陸,注意冒號後的空格
敲兩次回車確認,獲得服務器的回覆:
[c-sharp] view plaincopy
固然了,咱們最關心的是如何經過腳原本實現自動化.在鑑權成功後,就能夠進行數據包交換了.數據包包的類型在第一行定義.客戶端發送Action 包,服務器響應Response或者發送Event包.另外數據包中行的順序是不相關的.每一行使用CR(回車)或LF(換行)來結束.整個數據包使用一 個額外的回車或換行來結束.一個AMI終端一般爲每個Action發送一個隨機可是惟一的ActionID,服務器使用這個ActionID在 Response中來管理重疊的數據包流(packet stream).
服務器發送終端Event數據包,能夠關聯任何事件,每個事件就是一行,包括終端初始化Action.這種狀況下,服務器發 送"Response:Follows",緊接初始action的ActionID事件(行)後,接着是一個關閉事件(一般是 actionnameComplete).
若是你的終端不須要事件響應,他能夠經過包含"Events:off"語句在鑑權數據包中,來關閉這些通知.這樣設置後,AMI將只回應終端初始化的actions.
If your client has no need for events, it can turn off these notifications by including Events: off
in the authentication packet. Once set, the AMI sends only responses to actions initiated by the client.
下面是可用命令表:
Asterisk manager commands
===================================
http://blog.chinaunix.net/uid-26456800-id-3314719.html
測試緣由,須要搭建一個voip的環境,原來的人馬裝了一臺trixbox,我並不想單獨爲這個弄一臺機器,因此就嘗試在ubuntu上搭。 asterisk配置起來很複雜,折騰了半天沒搞定,想要安freepbx,結果弄了1天多也沒弄上,安裝時死活連不上數據庫(目前懷疑有多是權限問 題),最後選用了asterisk-gui.感受不錯。安裝過程也遇到了很多麻煩。記錄以下:
if ( resp_lower.contains("branches/1.6") || resp_lower.contains("asterisk/1.6") || resp_lower.contains("svn-branch-1.6") || resp_lower.contains("svn-trunk-") ) .. |
replace: if ( resp_lower.contains("branches/1.6") || resp_lower.contains("asterisk/1.6") || resp_lower.contains("svn-branch-1.6") || resp_lower.contains("svn-trunk-") || resp_lower.contains("asterisk/1.8") ) |
http://www.telecom-cafe.com/forum/viewthread.php?tid=3316
=================================
http://www.cnblogs.com/IcefishBingqing/p/3427112.html
Asterisk控制接口(AMI)容許管理客戶端程序鏈接到一個asterisk實例而且能夠經過TCP/IP流發送命令或讀取事件。這在試圖跟蹤asterisk的狀態或其中的電話客戶端狀態時頗有用,AMI說明了客戶端基於的通常(多是動態的)規則。
一種簡單的"key: value"協議用於已鏈接的管理客戶端和asteriskPBX之間的信息傳遞。每行都用回車換行(/r/n)來結束。
協議特色:
在發送命令前,你必須創建一個鏈接。
在認證後,數據包任什麼時候間均可以在兩個方向上互相傳輸。
數據包第一行爲"Action"時代表是由管理客戶端發送到asterisk,第一行爲"Event"或"Response"代表有asterisk發送到管理客戶端。數據包內各行順序能夠變化,對數據包沒有影響。
回車換行因爲區分每一行,空行(兩個連續回車換行)用於代表命令結束,Asterisk開始處理命令。
數據包類型:
數據包的類型經過一下幾種關鍵字來劃分
Action:一個由管理客戶端發送到Asterisk的數據包,請求執行特定的動做。只有有限的幾種動做供客戶端使用,每一個動做是由Asterisk服務器上的模塊所決定的。一次只能執行一個動做,該動做數據包包含了動做名稱以及執行所必需的參數。
Response:Asterisk對管理客戶端動做的響應。
Event: 有關Asterisk核心或擴展模塊發生事件的信息。
創建管理鏈接和用戶身份驗證:
爲 了與Asterisk進行管理通話,管理客戶端必須創建到Asterisk服務器偵聽端口(通常是5038)的TCP/IP鏈接,並使用登錄動做進行身份 驗證。這就要求在Asterisk服務器上建立用戶帳戶,用戶帳戶在/etc/asterisk/manager.conf中配置。帳戶由容許登錄的主 機,登陸密碼以及被授予的權限列表組成。
登陸和身份驗證的經理,你必須發送一個" 登陸 "行動,用您的用戶名和祕密(密碼做爲參數)。 Here is an example:下面是一個例子:
Action: login
Username: admin
Secret: secret
你還能夠經過"Events: off"阻止事件數據包發送到你的鏈接。例如:
Action: login
Username: admin
Secret: secret
Events: off
動做數據包:
向Asterisk發送動做時,額外的關鍵字能夠提供進一步的動做信息。例如,你可能但願指定號碼或通道的斷開。此外,若是您的操做會致使Asterisk來執行撥號規則中的條目,你能夠傳遞變量給撥號規則。這與你傳遞關鍵字的方式是同樣的。
向Asterisk發送動做數據包時,按照如下格式:
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>
管理動做( Action ):
經過CLI命令show manager commands的輸出結果就是管理動做列表。
具體以下:
AbsoluteTimeout :這個命令將要求Asterisk在指定秒數後掛斷特定的通道,從而有效地結束通話。
參數:
Channel :哪些渠道掛斷,如SIP/123-1c20
Timeout :到通道應掛斷的秒數
例子:
請求信息
Action: AbsoluteTimeout
Channel: SIP/123-1c20
Timeout: 20
返回成功信息
Response: Success
Message: Timeout Set
返回失敗信息
Response: Error
Message: No such channel
ChangeMonitor :更改記錄某通道信息文件名。
參數:
Channel:通道名稱
File:文件名
例子:
發送請求
ACTION: ChangeMonitor
Channel: SIP/x7065558529-1c20
File: 20050103-140105_cc51
返回失敗信息
Response: Error
Message: No such channel
返回成功信息
Response: Success
Message: Stopped monitoring channel
Command :發送Asterisk CLI命令。
參數:
Command:Asterisk CLI 命令。
例子:
發送請求
ACTION: COMMAND
command: Show Channels
返回信息
Response: Follows
Channel (Context Extension Pri ) State Appl. Data
0 active channel(s)
--END COMMAND-
注意:返回的事件響應結果並非發送一個回車換行(/r/n),而只發送回車(/n),若是你在中斷處理程序中只等待回車換行,那麼這條信息將會被被拋棄。
例如command返回信息以下:
Response: Follows/r/n
Channel Location State Application(Data)/n
SIP/x7065551212b-1af (None) Ringing AppDial((Outgoing Line))/n
SIP/x7065551212c-2aa 29@default:2 Ring Dial(SIP/x7065551212b)/n
2 active channels/n
1 active call/r/n
--END COMMAND--/r/n
/r/n
Events :事件控制流,用於啓用/禁用發送給管理客戶端的事件。
參數:
EventMask: 'on'表示全部事件均會被髮送到管理客戶端。
'off'表示全部時間都不會被髮送。
'system,call,log'用於選擇被髮送的事件。
提示:有些事件是啓用或禁已經在.conf文件中配置了, They might be disabled by default.他們多是默認爲禁用。
例子:
注意在此例子中EventMask事件沒有當即返回的響應信息,只有在設備註銷時才返回相關信息。
發送請求:
ACTION: EVENTS
EVENTMASK: ON
返回信息:
Event: PeerStatus
Peer: SIP/ChannelName
PeerStatus: Unregistered
Cause: Expired
當EventMask參數爲'off'時會當即返回響應信息,以下:
發送:
ACTION: EVENTS
EVENTMASK: OFF
返回:
Response: Events Off
ExtensionState :檢查分機的狀態。
參數:Exten,Context,ActionID
例子:
發送:
ACTION: ExtensionState
Context: default
Exten: 2001
ActionID: 1
接收:
Response: Success
ActionID: 1
Message: Extension Status
Exten: 2001
Context: default
Hint: SIP/2001
Status: 0
Status狀態代碼:
-1 =擴展找不到
0 =空閒
1 =在使用
2 =忙
4 =不可用
8 =振鈴
16 =正等待
GetVar:獲取一個通道變量。
參數:Channel,Variable,actionID
ActionID是一個可選的參數匹配信息。
例子:
發送:
ACTION: GetVar
Channel: SIP/5060-44d225d0
Variable: extension
成功返回:
Response: Success
Value: 17065551419
失敗返回:
Response: Error
Message: No such channel
或
Response: Success
varname: (null)
Hangup:掛斷指定通道。
參數:Channel
例子:
發送:
ACTION: Hangup
Channel: SIP/x7065558529-99a0
接收:
Event: Unlink
Channel1: SIP/127.180.254.109-44df88e8
Channel2: SIP/x7065558529-99a0
Uniqueid1: 1124989110.20473
Uniqueid2: 1124989110.20474
Event: Hangup
Channel: SIP/x7065558529-99a0
Uniqueid: 1124989110.20474
Cause: 16
Event: Hangup
Channel: SIP/127.180.254.109-44df88e8
Uniqueid: 1124989110.20473
Cause: 16
Response: Success
Message: Channel Hungup
IAXpeers :顯示iax信息列表。
例子:
發送:
Action: IAXPeers
接收:
Name/Username Host Mask Port Status
8002 (Unspecified) (D) 255.255.255.255 0 UNKNOWN
8001 192.168.0.91 (D) 255.255.255.255 4569 OK (5 ms)
2 iax2 peers [1 online, 1 offline, 0 unmonitored]
ListCommands :顯示命令列表。
參數:ActionID
例子:
發送:
Action:ListCommands
接收:Response: Success
AbsoluteTimeout: Set Absolute Timeout (Priv: call,all)
AgentCallbackLogin: Sets an agent as logged in by callback (Priv: agent,all)
AgentLogoff: Sets an agent as no longer logged in (Priv: agent,all)
Agents: Lists agents and their status (Priv: agent,all)
ChangeMonitor: Change monitoring filename of a channel (Priv: call,all)
Command: Execute Asterisk CLI Command (Priv: command,all)
DBGet: Get DB Entry (Priv: system,all)
DBPut: Put DB Entry (Priv: system,all)
Events: Control Event Flow (Priv: )
ExtensionState: Check Extension Status (Priv: call,all)
Getvar: Gets a Channel Variable (Priv: call,all)
Hangup: Hangup Channel (Priv: call,all)
IAXnetstats: Show IAX Netstats (Priv: )
IAXpeers: List IAX Peers (Priv: )
ListCommands: List available manager commands (Priv: )
Logoff: Logoff Manager (Priv: )
MailboxCount: Check Mailbox Message Count (Priv: call,all)
MailboxStatus: Check Mailbox (Priv: call,all)
MeetmeMute: Mute a Meetme user (Priv: call,all)
MeetmeUnmute: Unmute a Meetme user (Priv: call,all)
Monitor: Monitor a channel (Priv: call,all)
Originate: Originate Call (Priv: call,all)
Park: Park a channel (Priv: call,all)
ParkedCalls: List parked calls (Priv: )
PauseMonitor: Pause monitoring of a channel (Priv: call,all)
Ping: Keepalive command (Priv: )
PlayDTMF: Play DTMF signal on a specific channel. (Priv: call,all)
QueueAdd: Add interface to queue. (Priv: agent,all)
QueuePause: Makes a queue member temporarily unavailable (Priv: agent,all)
QueueRemove: Remove interface from queue. (Priv: agent,all)
Queues: Queues (Priv: )
QueueStatus: Queue Status (Priv: )
Redirect: Redirect (transfer) a call (Priv: call,all)
SetCDRUserField: Set the CDR UserField (Priv: call,all)
Setvar: Set Channel Variable (Priv: call,all)
SIPpeers: List SIP peers (text format) (Priv: system,all)
SIPshowpeer: Show SIP peer (text format) (Priv: system,all)
Status: Lists channel status (Priv: call,all)
StopMonitor: Stop monitoring a channel (Priv: call,all)
UnpauseMonitor: Unpause monitoring of a channel (Priv: call,all)
UserEvent: Send an arbitrary event (Priv: user,all)
WaitEvent: Wait for an event to occur (Priv: )
ZapDialOffHook: Dial over channel while offhook (Priv: )
ZapDNDoff: Toggle channel Do Not Disturb status OFF (Priv: )
ZapDNDon: Toggle channel Do Not Disturb status ON (Priv: )
ZapHangup: Hangup Channel (Priv: )
ZapRestart: Fully Restart channels (terminates calls) (Priv: )
ZapShowChannels: Show status channels (Priv: )
ZapTransfer: Transfer Channel (Priv: )
Logoff :註銷管理客戶端。
例子:
發送:
ACTION: LOGOFF
接收:
Response: Goodbye
Message: Thanks for all the fish.
MailboxCount :檢查語音信箱是否有新信息。
參數:MailBox,actionID
例子:
發送:
Action: MailboxCount
Mailbox: 2001@device
接收:
Response: Success
Message: Mailbox Message Count
Mailbox: 2001@device
NewMessages: 1
OldMessages: 0
MailboxStatus:檢查語音信箱狀態。
參數:MailBox,actionID
例子:
發送:
Action: MailboxStatus
Mailbox: 2001@device
接收:
Response: Success
Message: Mailbox Status
Mailbox: 2001@device
Waiting: 1
Monitor:監聽某個通道。
參數:Channel, File, Format, Mix
例子:
發送:
ACTION: Monitor
Channel: SIP/x7062618529-643d
File: channelsavefile
Mix: 1
返回:
Response: Success
Message: Started monitoring channel
失敗返回
Response: Error
Message: No such channel
Originate :產生一個呼叫。(privilege: call,all)
參數:
Channel:呼叫鏈接產生的通道。
Context:呼叫鏈接所使用的Context(Context,Exten,Priority必須同時使用)
Exten: 呼叫鏈接所使用的分機(Context,Exten,Priority必須同時使用)
Priority:呼叫鏈接的優先級。(Context,Exten,Priority必須同時使用)
TimeOut:呼叫鏈接的超時(,單位爲毫秒,默認爲30000毫秒)
CallID:呼叫鏈接的來電顯示。
Variable:通道變量設置。本地通道和鏈接通道都將被設置。
Account:呼叫所用密碼。
Application:使用這次呼叫的應用程序。(使用參數和數據)
Data:應用程序參數所使用的數據。
Async:呼叫是否爲異步。(容許屢次調用不等待響應生成)
ActionID:請 求標識符。 It allows you to identify the response to thisrequest.它容許您肯定這一請求的響應信息。 You may use a number or a string. Useful whenyou make several simultaneous requests.當您有用幾個併發請求,您可使用一個數字或字符串來區分。
事件的順序:首先SGI通道鳴響,而後當他被接聽後,經過上下文呼叫另外一端的分機。注意超時只用於呼叫通道,呼叫分機時的超時另外指定。
使用異步致使1 OriginateResponse事件,包含了失敗的緣由。 Reason may be one of the following:緣由多是下列之一:
0 = no such extension or number 0 =沒有這樣的延長或編號
1 = no answer 1 =無應答
4 = answered 4 =回答
8 = congested or not available 8 =擁擠或不可用
例1(從SIP通道呼叫一個分機,這將致使外部呼叫沒法產生直到sip通道掛斷)
發送:
Action: Originate
Channel: SIP/101test
Context: default
Exten: 8135551212
Priority: 1
Callerid: 3125551212
Timeout: 30000
Variable: var1=23|var2=24|var3=25
ActionID: ABC45678901234567890
分機8135551212是外呼號碼。這個例子代表了變量的使用方法
例2(從呼出通道呼叫一個本地分機,這將致使該分機再也不響鈴直到zap通道掛斷)
發送:
Action: Originate
Channel: Zap/g2/8135551212
Context: default
Exten: 101
Priority: 1
Timeout: 30000
Callerid: 3125551212
101爲一個本地分機號。
例3(運行系統命令)
發送:
Action: Originate
Channel: Local/1@dummy
Application: system
Data: /path/to/script
提示:若是你但願通道鏈接到任意分機和上下文,須要指定一個本地通道
ParkedCalls :設置顯示保持的呼叫列表。
參數:ActionID
發送:
Action: PakedCalls
返回:
Response: Success
Message: Parked calls will follow
Event: ParkedCallsComplete
Ping
例子:
發送:
Action: ping
返回:
Response: Pong
QueueAdd :添加隊列成員。
參數:
Queue:添加成員的隊列名。
Interface: 成員名(例如sip/2001)
Penalty:數值,值越高越靠後。
Paused:暫停(true)或不暫停(false)
ActionID:(前面已介紹)
例子:
發送:
Action: QueueAdd
Queue: 200
Interface: sip/3001
Penalty: 1
Paused: true
返回:
Response: Success
Message: Added interface to queue
Event: QueueMemberAdded
Privilege: agent,all
Queue: 200
Location: sip/3001
MemberName: sip/3001
Membership: dynamic
Penalty: 1
CallsTaken: 0
LastCall: 0
Status: 5
Paused: 1
QueueRemove :移除隊列成員。
參數:
Queue:移除成員的隊列名。
Interface: 成員名(例如sip/2001)
例子:
發送:
Action: QueueRemove
Queue: 200
Interface: sip/3001
返回:
Response: Success
Message: Removed interface from queue
Event: QueueMemberRemoved
Privilege: agent,all
Queue: 200
Location: sip/3001
MemberName: sip/3001
Queues :返回所有隊列的配置以及電話數據信息。
例子:
發送:
Action: Queues
返回:
200 has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime), W:0, C:0, A:0, SL:0.0% within 0s
Members:
Local/2002@from-internal/n (Invalid) has taken no calls yet
Local/2003@from-internal/n (Invalid) has taken no calls yet
Local/2001@from-internal/n (Invalid) has taken no calls yet
No Callers
default has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime), W:0, C:0, A:0, SL:0.0% within 0s
No Members
No Callers
QueueStatus :返回所有隊列的電話數據信息。
例子:
發送:
Action: QueueStatus
返回:
Response: Success
Message: Queue status will follow
Event: QueueParams
Queue: 200
Max: 0
Calls: 0
Holdtime: 0
Completed: 0
Abandoned: 0
ServiceLevel: 0
ServicelevelPerf: 0.0
Weight: 0
Event: QueueMember
Queue: 200
Name: Local/2002@from-internal/n
Location: Local/2002@from-internal/n
Membership: static
Penalty: 0
CallsTaken: 0
LastCall: 0
Status: 4
Paused: 0
Event: QueueMember
Queue: 200
Name: Local/2003@from-internal/n
Location: Local/2003@from-internal/n
Membership: static
Penalty: 0
CallsTaken: 0
LastCall: 0
Status: 4
Paused: 0
Event: QueueMember
Queue: 200
Name: Local/2001@from-internal/n
Location: Local/2001@from-internal/n
Membership: static
Penalty: 0
CallsTaken: 0
LastCall: 0
Status: 4
Paused: 0
Event: QueueParams
Queue: default
Max: 0
Calls: 0
Holdtime: 0
Completed: 0
Abandoned: 0
ServiceLevel: 0
ServicelevelPerf: 0.0
Weight: 0
Event: QueueStatusComplete
Redirect :重定向一個呼叫。
參數:
Channel:重定向的通道。
ExtraChannel:重定向的第二通道(可選)
Exten:重定向的分機。
Context: 重定向的上下文。
Priority:重定向的優先級
ActionID:(可選)
例子(把兩個呼叫重定向到meetme房間)
Action: Redirect
Channel: Zap/73-1
ExtraChannel: SIP/199testphone-1f3c
Exten: 8600029
Context: default
Priority: 1
8600029的上下文是default,並將進入meetme房間。
SetCDRUserField :設置用戶的呼叫詳細記錄。
參數:UserField,Channel,Append
SetVar :設置通道變量。
參數:Channel, Variable, Value
例子:
發送:
Action: Setvar
Channel: Zap/1-1
Variable: AtestVariable
Value: This is now set
SIPpeers :顯示sip用戶列表。
例子:
發送:
Action: SIPpeers
返回
Response: Success
Message: Peer status list will follow
Event: PeerEntry
Channeltype: SIP
ObjectName: 3001
ChanObjectType: peer
IPaddress: -none-
IPport: 0
Dynamic: yes
Natsupport: yes
VideoSupport: no
ACL: no
Status: UNKNOWN
RealtimeDevice: no
Event: PeerEntry
Channeltype: SIP
ObjectName: 2003
ChanObjectType: peer
IPaddress: -none-
IPport: 0
Dynamic: yes
Natsupport: yes
VideoSupport: no
ACL: no
Status: UNKNOWN
RealtimeDevice: no
Event: PeerEntry
Channeltype: SIP
ObjectName: 2002
ChanObjectType: peer
IPaddress: -none-
IPport: 0
Dynamic: yes
Natsupport: yes
VideoSupport: no
ACL: no
Status: UNKNOWN
RealtimeDevice: no
Event: PeerEntry
Channeltype: SIP
ObjectName: 2001
ChanObjectType: peer
IPaddress: -none-
IPport: 0
Dynamic: yes
Natsupport: yes
VideoSupport: no
ACL: no
Status: UNKNOWN
RealtimeDevice: no
Event: PeerlistComplete
ListItems: 4
Status :返回全部開放通道或指定通道的狀態。
參數:Channel (可選), ActionID (可選)
例子:
發送:
Action:Status
返回:
Response: Success
Message: Channel status will follow
Event: StatusComplete
StopMonitor :中止檢測某通道。
參數:Channel
例子:
發送:
Action: StopMonitor
Channel: Zap/1-1
ZapDialOffhook :從空閒的ZAP通道撥打呼叫。
參數:
ZapChannel: ZAP 通道
Number: 所撥打的號碼
ZapDNDoff :綁定ZAP通道而不影響其關閉狀態
參數:ZAPChannel
ZapDNDon :綁定ZAP通道而不影響其開放狀態
參數:ZAPChannel
ZapHangup :掛斷ZAP通道。
參數:ZAPChannel
ZapTransfer :轉撥ZAP通道。
參數:ZAPChannel
ZapShowChannels :顯示全部ZAP通道信息。
參數:ActionID(可選)
Asterisk 1.2.1新增:
AgentCallBackLogin :設置用戶以回撥方式登陸。
參數:
Agent:用戶登陸的ID
Exten: 用於回撥的分機
Context: 用於回撥的上下文
AckCall: 設置在用戶回撥時進行驗證
WrapupTime: 掛斷重撥的最小間隔時間
ActionID:
例子:
發送:
Action: AgentCallBackLogin
Agent: 1234
Exten: 1234
Context: myqueues
AckCall: true
WrapupTime: 30
ActionID: 12345
AgentLogoff :註銷一個用戶。
參數:
Agent:用戶登陸Id
例子:
發送:
Action: AgentLogoff
Agent: 1234
Agents :顯示全部用戶信息。
例子:
發送:
Action: Agents
DBGet :查詢數據庫信息。
參數:Family,Key
發送:
Action: DBGet
Family:
Key:
失敗返回:
Response: Error
Message: Database entry not found
成功返回:
Response: Success
Message: Result will follow
Event: DBGetResponse
Family:
Key:
Val:
在Perl腳本中的運用:
use Asterisk::Manager;
my $astman = new Asterisk::Manager;
$astman->user('');
$astman->secret('');
$astman->host('');
$astman->connect || die $astman->error . "/n";
$astman->sendcommand(Action => 'DBGet', Family => '', Key => '');
my @result = $astman->sendcommand(Event => 'DBGetResponse');
$astman->disconnect;
my $value = $result[7]; -> Value 7 is the returned Value
DBPut:更新數據庫信息。
發送:
Action: DBPut
Family:
Key:
Value: (note, as of Asterisk 1.4 The Manager API wants Val: )
返回:
Response: Success
Message: Updated database successfully
使用方法同DBGet同樣。
QueuePause :中止/開啓隊列中某個成員的使用。
參數:
Queue: 成員所在隊列名.(可選,如無此項將在成員所在的全部隊列中止成員的使用)
Interface: 隊列成員名 (如sip/1000, zap/1-1, agent/1000)
Paused: 中止或開啓 (true or false)
SIPshowPeer :顯示指定 peer 信息
參數: peer:指定的peer。
Asterisk 1.4.0新增:
PlayDTMF :在指定通道上發送雙音多頻信號數字。
參數:
Channel:指定的通道
Digit:雙音多頻信號數字
發送:
Action: PlayDTMF
Channel: SIP/123-e2b2
Digit: 1
成功返回:
Response: Success
Message: DTMF successfully queued
失敗返回:
Response: Error
Message: No such channel
UpdateConfig :更新配置文件。
參數:
SrcFilename: 要讀取的配置文件(.conf)
DstFilename: 要更新的配置文件(.conf)
Reload: 是否從新加載(asterisk或者模塊名稱)
Action-XXXXXX: 採起的動做 (NewCat、RenameCat、DelCat、Update、Delete、Append)
Cat-XXXXXX: 操做對象
Var-XXXXXX: 採用的變量
Value-XXXXXX: 變量的值
Match-XXXXXX: 其餘匹配信息
例1:(更新manager.conf)
action: updateconfig
reload: yes
srcfilename: manager.conf
dstfilename: manager.conf
action-000000: append
cat-000000: newuser
var-000000: secret
value-000000: nottelling
例2:(更新extension.conf,經過'>'增長前綴)
action:updateconfig
reload:yes
srcfilename: extensions.conf
dstfilename: extensions.conf
Action-000000:append
Cat-000000: ami-test
Var-000000: exten
Value-000000: >999,1,Dial(SIP/Bob)
例3:(刪除manager.conf中的配置信息)
action: updateconfig
srcfilename: manager.conf
dstfilename: manager.conf
action-000000: delete
cat-000000: newuser
var-000000: secret
value-000000: nottelling
match-000000: nottelling
刪除時必須設置'value'和'match',不設置'match'將會刪除變量爲'var'全部條目
GetConfig :顯示配置文件內容,主要給AJAM和asterisk圖形界面使用。
變量:FileName:顯示的文件名(.conf)。
Asterisk 事件( Event ) :
如下的事件都在asterisk源碼中定義。
用戶狀態事件:
'Agentcallbacklogin' 事件 :
描述:
[來源於chan_agent.c]
示例:
Event: Agentcallbacklogin
Agent:
Loginchan:
Uniqueid:
'Agentcallbacklogoff'事件
描述:
[來源於chan_agent.c]
示例:
Event: Agentcallbacklogoff
Agent:
Loginchan:
Logintime:
Reason: Autologoff
Uniqueid:
Event: Agentcallbacklogoff
Agent:
Loginchan:
Logintime:
Uniqueid:
'AgentCalled'事件
描述:
[來源於 app_queue.c]
示例:
Event: AgentCalled
AgentCalled:
ChannelCalling:
CallerID:
Context:
Extension:
Priority:
'AgentComplete'事件
描述:
[來源於 app_queue.c]
示例:
Event: AgentComplete
Queue:
Uniqueid:
Channel:
Member:
MemberName:
HoldTime:
TalkTime:
Reason:
'AgentConnect'事件
描述:
[來源於 app_queue.c]
示例:
Event: AgentConnect
Queue:
Uniqueid:
Channel:
Member:
MemberName:
Holdtime:
BridgedChannel:
'AgentDump'事件
描述:
[來源於 app_queue.c]
示例:
Event: AgentDump
Queue:
Uniqueid:
Channel:
Member:
MemberName:
'Agentlogin'事件
描述:
[來源於 chan_agent.c]
示例:
Event: Agentlogin
Agent:
Channel:
Uniqueid:
'Agentlogoff'事件
描述:
[來源於 chan_agent.c]
示例:
Event: Agentlogoff
Agent:
Logintime:
Uniqueid:
'QueueMemberAdded'事件
描述:
隊列增長成員動做
[來源於 app_queue.c]
示例:
Queue: testing
Location: Agent/AgentId
Membership: dynamic
Penalty: 0
CallsTaken: 0
LastCall: 0
Status: 4
Paused: 1
'QueueMemberPaused'事件
描述:
響應動做: QueuePause
[來源於 app_queue.c]
示例:
Event: QueueMemberPaused
Location:
MemberName:
Paused:
'QueueMemberStatus'事件
描述:
[來源於 app_queue.c]
Status的值可能爲:
/*設備是有效的,但不知道的通道狀態*/
define AST_DEVICE_UNKNOWN 0
/*設備沒有使用 */
define AST_DEVICE_NOT_INUSE 1
/*設備使用中 */
define AST_DEVICE_INUSE 2
/*設備忙 */
define AST_DEVICE_BUSY 3
/*設備無效 */
define AST_DEVICE_INVALID 4
/*設備不可用 */
define AST_DEVICE_UNAVAILABLE 5
/* 設備在響鈴*/
define AST_DEVICE_RINGING 6
/*設備在響鈴並在使用中*/
define AST_DEVICE_RINGINUSE 7
/*設備在等待 */
define AST_DEVICE_ONHOLD 8
示例:
Event: QueueMemberStatus
Queue:
Location:
MemberName:
Membership:
Penalty: CallsTaken:
LastCall:
Status:
Paused:
-
命令狀態事件:
呼叫狀態事件:
'CDR'事件
描述:
[來源於 cdr_manager.c]
必須在 cdr_manager.conf 配置文件中有:
general
enabled = yes
示例:
Event: Cdr
AccountCode:
Source:
Destination:
DestinationContext:
CallerID:
Channel:
DestinationChannel:
LastApplication:
LastData:
StartTime:
AnswerTime:
EndTime:
Duration:
BillableSeconds:
Disposition:
AMAFlags:
UniqueID:
UserField:
'Dial'事件
描述:
[來源於 app_dial.c]
示例:
Event: Dial
Privilege: call,all
Source: Local/900@default-2dbf,2
Destination: SIP/900-4c21
CallerID:
CallerIDName: default
SrcUniqueID: 1149161705.2
DestUniqueID: 1149161705.4
'ExtensionStatus'事件
描述:
[來源於 manager.c]
示例:
Event: ExtensionStatus
Exten:
Context:
Status:
'Hangup'事件
描述:
[來源於 channel.c]
示例:
Event: Hangup
Channel: SIP/101-3f3f
Uniqueid: 1094154427.10
Cause: 0
Cause 代碼:
未分配 = 1
無到達路由 = 2
無路由目的地 = 3
無效通道 = 6
正在通話中 = 7
正常掛機 = 16
用戶忙 = 17
無應答 = 18
無人接聽 = 19
拒絕接聽 = 21
號碼已更改 = 22
目的次序不對 = 27
無效的數字格式 = 28
設備拒絕 = 29
查詢響應 = 30
正常未指定 = 31
正常的呼叫擁塞 = 34
網絡狀態差 = 38
正常的臨時故障 = 41
交換機擁塞 = 42
信息過期 = 43
請求通道無效 = 44
被搶佔 = 45
無呼叫保持或呼叫等待 = 50
禁止呼出 = 52
禁止呼入 = 54
負載太重致使失效 = 57
負載過多致使不可達 = 58
負載過多致使爲實現 = 65
通道未實現 = 66
設備未實現 = 69
無效的呼叫證實 = 81
不相容的目的地 = 88
無效的不明信息 = 95
IE瀏覽器關閉 = 96
不識別的信息類型 = 97
錯誤信息 = 98
無IE瀏覽器 = 99
無效的IE信息 = 100
呼叫狀態錯誤 = 101
計時到達 = 102
強制性IE瀏覽器長度偏差 = 103
協議錯誤 = 111
互通 = 127
未定義的 = 0
'MusicOnHold'事件
描述:
事件表示電話等待時,播放音樂
示例:
Event: MusicOnHold
Channel:
State:
Uniqueid:
'Join'事件
描述:
[來源於 app_queue.c]
示例:
Event: Join
Channel:
CallerID:
Queue:
Position:
Count:
'Leave'事件
描述:
[來源於 app_queue.c]
示例:
Event: Leave
Channel:
Queue:
Count:
'Link'事件
描述:
當兩個通道已鏈接後開始交換聲音數據時發生'link'事件
示例:
Event: Link
Channel1: SIP/101-3f3f
Channel2: Zap/2-1
Uniqueid1: 1094154427.10
Uniqueid2: 1094154427.11
'MeetmeJoin'事件
描述:
[來源於 app_meetme.c]
示例:
Event: MeetmeJoin
Channel:
Uniqueid:
Meetme:
Usernum:
'MeetmeLeave'事件
描述:
[來源於 app_meetme.c]
示例:
Event: MeetmeLeave
Channel:
Uniqueid:
Meetme:
Usernum:
'MeetmeStopTalking'事件
描述:
[來源於 app_meetme.c]
注意:
這要求在meetme應用中以選中T選
示例:
Event: MeetmeStopTalking
Privilege: call,all
Channel: SIP/200-ABC1
Uniqueid: 1234567890.1
Meetme: 400
Usernum: 2
'MeetmeTalking'事件
描述:
[來源於 app_meetme.c]
注意:
這要求在meetme應用中以選中T選項
示例:
Event: MeetmeTalking
Privilege: call,all
Channel: SIP/200-ABC1
Uniqueid: 1234567890.1
Meetme: 400
Usernum: 2
'MessageWaiting'事件
描述:
[來源於 app_voicemail.c]
示例:
Event: MessageWaiting
Mailbox: @
Waiting:
New:
Old:
Event: MessageWaiting
Mailbox:
Waiting:
'Newcallerid'事件
描述:
[來源於 channel.c]
示例:
Event: Newcallerid
Channel:
Callerid:
Uniqueid:
'Newchannel'事件
描述:
[來源於 channel.c]
示例:
Event: Newchannel
Channel: Zap/2-1
State: Rsrvd
Callerid:
Uniqueid: 1094154427.11
Event: Newchannel
Channel: SIP/101-3f3f
State: Ring
Callerid: 101
Uniqueid: 1094154427.10
'Newexten'事件
描述:
當一項PBX函數運行(例如執行撥號規則)時發生此事件。
示例:
Event: Newexten
Channel: SIP/101-00c7
Context: macro-ext
Extension: s
Priority: 3
Application: Goto
AppData: s-BUSY
Uniqueid: 1094154321.8
Event: Newexten
Channel: SIP/101-3f3f
Context: local_extensions
Extension: 917070
Priority: 1
Application: AGI
AppData: /etc/asterisk/agi/ks_doorman_pickup.py|channel_up
Uniqueid: 1094154427.10
Event: Newexten
Channel: SIP/101-3f3f
Context: local_extensions
Extension: 917070
Priority: 2
Application: Dial
AppData: Zap/G1/17070
Uniqueid: 1094154427.10
'ParkedCall'事件
描述:
[來源於 res_features.c]
示例:
Event: ParkedCall
Exten: Channel:
From:
Timeout:
CallerID:
'Rename'事件
描述:
[來源於 channel.c: channel 'rename' event]
示例:
Event: Rename
Oldname:
Newname:
Uniqueid:
'SetCDRUserField'事件
描述:
[來源於 app_setcdruserfield.c]
示例:
'Unlink'事件
描述:
當兩個鏈接的通道斷開是發生此事件,一般爲掛機時
示例:
Event: Unlink
Channel1: SIP/101-3f3f
Channel2: Zap/2-1
Uniqueid1: 1094154427.10
Uniqueid2: 1094154427.11
'UnParkedCall'事件
描述:
[來源於 res_features.c]
日誌狀態事件:
系統狀態事件:
'Alarm'事件:
描述:
[來源於 chan_zap.c]
示例:
Event: Alarm
Alarm:<(Red|Yellow|Blue|No|Unknown)Alarm|Recovering|Loopback|Not Open|None>
Channel:
'AlarmClear'事件:
描述:
[來源於 chan_zap.c]
示例:
Event: AlarmClear
Channel:
'DNDState'事件:
描述:
[來源於 chan_dahdi.c]
示例:
Event: DNDState
Channel: Zap/1
Status:
'LogChannel'事件
描述:
[來源於 logger.c]
示例:
Event: LogChannel
Channel: /var/log/asterisk/messages
Enabled: Yes
Event: LogChannel
Channel: /var/log/asterisk/messages
Enabled: No
Reason: 13 - Permission denied
'PeerStatus'事件
描述:
當用戶註冊或註銷時發生此事件
[來源於 chan_sip.c, chan_iax2.c]
示例:
Event: PeerStatus
Peer: SIP/2005
PeerStatus: Registered
Event: PeerStatus
Peer: SIP/2005
PeerStatus: Unregistered
Cause: Expired
Event: PeerStatus
Peer: IAX2/2007
PeerStatus:
Time: 1000
'Registry'事件
描述:
當應戶註冊時發生的事件
[來源於 chan_sip.c, chan_iax2.c]
示例:
Event: Registry
Channel: SIP
Domain: sip.domain
Status: Registered
'Reload'事件
描述:
當 "RELOAD" 命令執行時發生此事件
[來源於 manager.c]
示例:
Event: Reload
Message: Reload Requested
'Shutdown'事件
描述:
[來源於 asterisk.c]
示例:
Event: Shutdown
Shutdown:
Restart: [tr]
User Status 事件:
'UserEvent'事件
描述:
[來源於 app_userevent.c]
示例:
Event:
Channel:
Uniqueid:
Event:
Channel:
Uniqueid:
詳細狀態事件:
'Newstate'事件
示例:
Event: Newstate
Channel: Zap/2-1
State: Dialing
Callerid: 101
Uniqueid: 1094154427.11
Event: Newstate
Channel: Zap/2-1
State: Up
Callerid: 101
Uniqueid: 1094154427.11
'ParkedCallsComplete:'事件
描述:
發生在ParkedCalls事件以後
示例:
Event: ParkedCallsComplete
'QueueParams:'事件
描述:
響應Queues動做的事件
示例:
Event: QueueParams
Queue: sales
Max: 0
Calls: 0
Holdtime: 0
Completed: 0
Abandoned: 0
ServiceLevel: 0
ServicelevelPerf: 0.0
'QueueMember'事件
描述:
響應Queues動做而且隊列中有成員是發生的事件。
示例:
Event: QueueMember
Queue: sales
Location: SIP/101
Membership: dynamic
Penalty: 0
CallsTaken: 0
LastCall: 0
'QueueStatusEnd'事件
描述:
響應Queues動做表示輸出結束。
示例:
Event: QueueStatusEnd
'Status'事件
示例:
Event: Status
Channel: Zap/2-1
CallerID: 101
Account:
State: Up
Link: SIP/101-5cf0
Uniqueid: 1094166088.26
Event: Status
Channel: SIP/101-5cf0
CallerID: 101
Account:
State: Up
Context: local_extensions
Extension: 917070
Priority: 2
Seconds: 11
Link: Zap/2-1
Uniqueid: 1094166088.25
'StatusComplete'事件
描述:
響應Status動做的事件,表示狀態輸出結束。
示例:
Event: StatusComplete
'ZapShowChannels'事件
描述:
響應ZapShowChannels動做的事件。
示例:
Event: ZapShowChannels
Channel: 2
Signalling: FXS Kewlstart
Context: pstn_menu
Alarm: No Alarm
'ZapShowChannelsComplete事件
描述:
響應ZapShowChannels動做的事件,表示輸出結束。
示例:
Event: ZapShowChannelsComplete
動做響應( Response ) 格式:Response: ( Success或Error)Message: (顯示信息)示例:無動做或輸入有誤:Response: ErrorMessage: Missing action in request未知命令:Response: ErrorMessage: Invalid/unknown command無權限:Response: ErrorMessage: Permission denied成功:Response: SuccessMessage: Zap channel status will follow