Asterisk ami-action: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
Line 529: Line 529:
* ApplicationData - Arguments to the application.
* ApplicationData - Arguments to the application.
* Replace - If set to 'yes', '1', 'true' or any of the other values we evaluate as true, then if an extension already exists at the requested context, extension, and priority it will be overwritten. Otherwise, the existing extension will remain and the action will fail.
* Replace - If set to 'yes', '1', 'true' or any of the other values we evaluate as true, then if an extension already exists at the requested context, extension, and priority it will be overwritten. Otherwise, the existing extension will remain and the action will fail.
'''Example'''
<pre>
Action: DialplanExtensionAdd
ActionID: 123456
Context: test_dialplan
Extension: test_exten
Priority: 1
Application: echo
Response: Success
ActionID: 123456
Message: Added requested extension
</pre>


=== DialplanExtensionRemove ===
=== DialplanExtensionRemove ===

Revision as of 22:27, 3 December 2015

Overview

Asterisk ami(Asteriskk Manager Interface) 명령어 정리.

Basic

Telnet 접속

/etc/asterisk/manager.conf 파일에 설정한 IP 주소 및 포트 번호를 이용하면 telnet 으로도 접속이 가능하다.

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

Help

Action 도움말 확인법

vpbx120*CLI> manager show command Logoff 
[Syntax]
Action: Logoff
[ActionID:] <value>

[Synopsis]
Logoff Manager. 

[Description]
Logoff the current manager session.

[Arguments]
ActionID
    ActionID for this transaction. Will be returned.

[See Also]
Not available

Access

Login

AMI login 을 한다.

Action: Login
ActionID: <value>
Username: <value>
Secret: <value>
  • Username : Access Username. manager.conf 에 설정되어 있다.
  • Secret : Password. manager.conf 에 설정되어 있다.

Logoff

AMI logoff 를 한다.

Action: Logoff
ActionID: <value>

Queue

QueueStatus

Queue/Member(Channel) 의 현재 상태 정보를 확인한다. 입력된 Queue/Member(Channel) 항목이 없다면 현재 활성화된 전체 Queue/Member(Channel) 의 상태 정보를 리턴한다.

Action: QueueStatus
ActionID: <value>
Queue: <value>
Member: <value>
  • Queue - 확인하고자 하는 Queue name.
  • Member - 확인하고자 하는 멤버(Channel) 이름

Example

Action: QueueStatus
Queue: Camp200
ActionID: 001

Response: Success
ActionID: 001
Message: Queue status will follow

Event: QueueParams
Queue: Camp200
Max: 0
Strategy: ringall
Calls: 0
Holdtime: 0
TalkTime: 0
Completed: 0
Abandoned: 0
ServiceLevel: 0
ServicelevelPerf: 0.0
Weight: 100
ActionID: 001

Event: QueueMember
Queue: Camp200
Name: user1
Location: Local/200@DialCamp
Membership: static
Penalty: 0
CallsTaken: 0
LastCall: 0
Status: 5
Paused: 0
ActionID: 001

Event: QueueEntry
Queue: Camp200
Position: 1
Channel: SIP/test-201-00000001
Uniqueid: 1447837150.7
CallerIDNum: 201
CallerIDName: user 2
ConnectedLineNum: unknown
ConnectedLineName: unknown
Wait: 16

Event: QueueStatusComplete
ActionID: 001

- QueueParam 정보

  • Event - 메시지 타입. QueueParam:Queue 정보, QueueMember:Queue에 속해있는 member 정보, QueueEntry:Queue에서 대기중인 콜 정보.
  • Queue - Queue name
  • Max - Queue에서 허용 가능한 최대 콜 수.
  • Strategy - 콜 분배 방식.(rignall|roundrobin|leastrecent|fewestcalls|random|rrmemory|linear|wrandom)
  • HoldTime - 현재 평균 큐 대기 시간.
  • Weight - 큐의 우선 순위. 높은(많은) 우선순위를 가진 큐의 콜이 낮은(적은) 우선순위를 가진 큐보다 먼저 분배될 확률이 높아진다.
  • ServiceLevel - ServiceLevelPerf 를 확인하는 Interval time(sec)
  • ServicelevelPerf - SerivceLevel 시간동안의 콜 응답률(%). 응답 콜 /전체 인입 콜 * 100
  • Calls - 현재 큐에서 대기중인 콜의 갯수.
  • Abandoned - 큐에서 대기중에 분배되지 못하고 끊어진 콜.
  • TalkTikme - 분배 후 평균 통화시간.
  • Completed - 정상적으로 분배 완료된 콜 갯수

- QueueMember 정보

  • Event - 메시지 타입. QueueParam:Queue 정보, QueueMember:Queue에 속해있는 member 정보, QueueEntry:Queue에서 대기중인 콜 정보.
  • Queue - Queue name
  • Name - Member name
  • Status - 멤버의 상태 번호
    • 0:AST_DEVICE_UNKNOWN
    • 1:AST_DEVICE_NOT_INUSE
    • 2:AST_DEVICE_INUSE
    • 3:AST_DEVICE_BUSY
    • 4:AST_DEVICE_INVALID
    • 5:AST_DEVICE_UNAVAILABLE
    • 6:AST_DEVICE_RINGING
    • 7:AST_DEVICE_RINGINUSE
    • 8:AST_DEVICE_ONHOLD
  • Location - 멤버의 Channel 정보 혹은 위치 정보
  • StateInterface - 멤버의 상태 정보를 확인하는 장치 정보.
  • Membership - 멤버의 등록 방법(dynamic|realtime|static).
    • dynamic - 동적 등록. AMI, Dialplan 등으로 등록된 방식.
    • static - 정적 등록. queues.conf 에 명시적으로 등록하여 등록된 방식.
    • static -
  • Penalty - 패널티 정보(높은 패널티를 가지게 되면 상대적으로 콜을 분배받기 어려워진다.)
  • CallsTaken - 분배받은 콜의 숫자
  • LastCall - 마지막으로 받은 콜의 시간. Unix 타임을 사용한다.
  • Paused - Paused 여부. (1:Paused 상태, 0:Normal 상태)

- QueueEntry 정보

  • Event - 메시지 타입. QueueParam:Queue 정보, QueueMember:Queue에 속해있는 member 정보, QueueEntry:Queue에서 대기중인 콜 정보.
  • Queue - Queue name
  • Position - Priority number of entry from the queue.
  • Channel - Channel name
  • Uniqueid - Unique id of Asterisk
  • CallerIDNum - Caller's number
  • CallerIDName - Caller's name
  • ConnectedLineNum - 현재 이 콜과 연결된(통화중인) number
  • ConnectedLineName - 현재 이 콜과 연결된(통화중인) name
  • Wait - 이 큐에서 대기한 시간(초)

QueueSummary

Queue의 간략 상태를 표시한다.

Action: QueueSummary
ActionID: <value>
Queue: <value>
  • Queue : Queue name

Example

Action: QueueSummary
Queue: Camp200

Response: Success
Message: Queue summary will follow

Event: QueueSummary
Queue: Camp200
LoggedIn: 1
Available: 1
Callers: 0
HoldTime: 0
TalkTime: 3
LongestHoldTime: 0

Event: QueueSummaryComplete
  • LoggedIn : 현재 로그인(활성화)되어 있는 멤버(Channel) 갯수
  • Available : 현재 대기중인 멤버(Channel) 갯수
  • Callers : 현재 큐에 인입되어 대기중인 콜 갯수
  • HoldTime : 콜이 큐에 인입되어 분배되기 까지의 평균 대기 시간
  • TalkTime : 콜이 큐에 인입되어 분배되고 난 후의 평균 통화 시간
  • LongestHoldTime : 큐에서 가장 오래 대기한 콜의 대기시간.

QueuePenalty

큐 멤버의 패널티를 설정한다.

Action: QueuePenalty
ActionID: <value>
Interface: <value>
Penalty: <value>
Queue: <value>
  • Interface : 패널티를 수정하고자 하는 멤버(Channel) 이름(tech/name).
  • Penalty : 설정하고자 하는 패널티 값. 단, 음수를 설정할수는 없다.
  • Queue : 패널티를 설정하고자하는 큐 이름. 만약 지정하지 않으면, 해당 멤버(Channel)이 속한 모든 큐에서 패널티 값을 수정하게 된다.

QueuePause

큐에 설정된 멤버(Channel)을 일시적 사용불가/사용가능 상태로 변경한다.

Action: QueuePause
ActionID: <value>
Interface: <value>
Paused: <value>
Queue: <value>
Reason: <value>
  • Interface : 사용가능/불가 상태로 지정하고자 하는 채널 혹은 인터페이스(tech/name)
  • Paused : "true": 사용불가, "false" : 사용가능
  • Queue : paused/unpaused 하고자 하는 큐 이름. 만약 지정하지 않으면, 해당 멤버(Channel)이 속한 모든 큐에서 paused/unpaused 를 하게 된다.
  • Reason : Description. QueueMemberPaused 이벤트에 설정되게 된다.

QueueReload

Queue를 reload한다. 하나 혹은 다수 Queue 또는 큐의 하위 섹션들을 reload 한다.

Action: QueueReload
ActionID: <value>
Queue: <value>
Members: <value>
Rules: <value>
Parameters: <value>
  • Queue : reload 하고자 하는 큐 이름. 만약 지정하지 않으면, 모든 큐에 대해 reload가 수행된다.
  • Members : Queue 의 멤버들의 reload 여부. (yes|no)
  • Rules : queuerules.conf 파일의 reload 여부. (yes|no)
  • Parameters : 다른 Queue 옵션들의 reload 여부. (yes|no)

QueueAdd

Action: QueueAdd
ActionID: <value>
Queue: <value>
Interface: <value>
Penalty: <value>
Paused: <value>
MemberName: <value>
StateInterface: <value>
  • Queue : Queue name
  • Interface : Queue에 추가하고자 하는 멤버(Channel) 이름(tech/name).
  • Penalty : 초기 설정 Penalty 값
  • Paused : Paused 설정(true/false 혹은 1/0)
  • MemberName : Interface 별명.
  • StateInterface : 멤버 State 를 받아오는 device 혹은 Channel 정보.

QueueRemove

Queue 에서 해당 멤버(Channel)를 삭제한다.

Action: QueueRemove
ActionID: <value>
Queue: <value>
Interface: <value>
  • Queue : Queue name
  • Interface : 삭제하고자 하는 멤버(Channel) 이름(tech/name)

QueueReset

Queue 관련 통계를 초기화한다.

Action: QueueReset
ActionID: <value>
Queue: <value>
  • Queue : Queue name

QueueRule

queuerules.conf 에 설정된 Queue Rule 을 보여준다.

Action: QueueRule
ActionID: <value>
Rule: <value>
  • Rule : queuerules.conf 파일에 설정되어 있는 Rule 이름.

Channel

Originate

발신을 한다.

Action: Originate
ActionID: <value>
Channel: <value>
Exten: <value>
Context: <value>
Priority: <value>
Application: <value>
Data: <value>
Timeout: <value>
CallerID: <value>
Variable: <value>
Account: <value>
EarlyMedia: <value>
Async: <value>
Codecs: <value>
ChannelId: <value>
OtherChannelId: <value>
  • Channel : 발신 목적지 채널
  • Exten : 발신 성공 후 연결될 Extension(Context, Priority 항목 설정 필요)
  • Context : 발신 성공 후 연결될 Context(Exten, Priority 항목 설정 필요)
  • Priority : 발신 성공 후 사용될 Priority(Exten, Context 항목 설정 필요)
  • Application : 발신 성공 후 실행될 Application
  • Data : Application 에 사용될 Data(Application 항목 설정 필요)
  • Timeout : 발신 후, 응답시까지의 timeout
  • CallerID : 발신 채널에 설정될 Caller ID
  • Variable : 채널 헤더에 설정될 임의 변수 값. 다중의 채널 헤더 변수 값 설정 가능.
  • Account  : Account code
  • EalryMedia : true 설정시, 강제로 early media 로 연결되게 된다.
  • Async : true 설정시, 곧바로 발신 성공값을 리턴한다.
  • Codes : 발신에 사용될 코덱 지정. 콤마로 구분자로 여러개의 값을 지정할 수 있다.
  • ChannelId : 채널에 설정될 유니크 아이디 값.
  • OtherChannelId : 다른쪽 로컬 채널에 설정될 유니크 아이디 값.

Hangup

채널을 종료한다.

Action: Hangup
ActionID: <value>
Channel: <value>
Cause: <value>
  • channel : 종료하고자하는 채널의 정확한 이름. 혹은 정규표현식도 가능하다.
Example exact channel: SIP/provider-0000012a
Example regular expression: /^SIP/provider-.*$/
  • Cause : 채널 종료 사유(숫자)

채널 종료 사유

#define AST_CAUSE_UNALLOCATED                    1
#define AST_CAUSE_NO_ROUTE_TRANSIT_NET           2
#define AST_CAUSE_NO_ROUTE_DESTINATION           3
#define AST_CAUSE_MISDIALLED_TRUNK_PREFIX        5
#define AST_CAUSE_CHANNEL_UNACCEPTABLE           6
#define AST_CAUSE_CALL_AWARDED_DELIVERED         7
#define AST_CAUSE_PRE_EMPTED                     8
#define AST_CAUSE_NUMBER_PORTED_NOT_HERE        14
#define AST_CAUSE_NORMAL_CLEARING               16
#define AST_CAUSE_USER_BUSY                     17
#define AST_CAUSE_NO_USER_RESPONSE              18
#define AST_CAUSE_NO_ANSWER                     19
#define AST_CAUSE_SUBSCRIBER_ABSENT             20
#define AST_CAUSE_CALL_REJECTED                 21
#define AST_CAUSE_NUMBER_CHANGED                22
#define AST_CAUSE_REDIRECTED_TO_NEW_DESTINATION 23
#define AST_CAUSE_ANSWERED_ELSEWHERE            26
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER      27
#define AST_CAUSE_INVALID_NUMBER_FORMAT         28
#define AST_CAUSE_FACILITY_REJECTED             29
#define AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY    30
#define AST_CAUSE_NORMAL_UNSPECIFIED            31
#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION     34
#define AST_CAUSE_NETWORK_OUT_OF_ORDER          38
#define AST_CAUSE_NORMAL_TEMPORARY_FAILURE      41
#define AST_CAUSE_SWITCH_CONGESTION             42
#define AST_CAUSE_ACCESS_INFO_DISCARDED         43
#define AST_CAUSE_REQUESTED_CHAN_UNAVAIL        44
#define AST_CAUSE_FACILITY_NOT_SUBSCRIBED       50
#define AST_CAUSE_OUTGOING_CALL_BARRED          52
#define AST_CAUSE_INCOMING_CALL_BARRED          54
#define AST_CAUSE_BEARERCAPABILITY_NOTAUTH      57
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL     58
#define AST_CAUSE_BEARERCAPABILITY_NOTIMPL      65
#define AST_CAUSE_CHAN_NOT_IMPLEMENTED          66
#define AST_CAUSE_FACILITY_NOT_IMPLEMENTED      69
#define AST_CAUSE_INVALID_CALL_REFERENCE        81
#define AST_CAUSE_INCOMPATIBLE_DESTINATION      88
#define AST_CAUSE_INVALID_MSG_UNSPECIFIED       95
#define AST_CAUSE_MANDATORY_IE_MISSING          96
#define AST_CAUSE_MESSAGE_TYPE_NONEXIST         97
#define AST_CAUSE_WRONG_MESSAGE                 98
#define AST_CAUSE_IE_NONEXIST                   99
#define AST_CAUSE_INVALID_IE_CONTENTS          100
#define AST_CAUSE_WRONG_CALL_STATE             101
#define AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE     102
#define AST_CAUSE_MANDATORY_IE_LENGTH_ERROR    103
#define AST_CAUSE_PROTOCOL_ERROR               111
#define AST_CAUSE_INTERWORKING                 127

/* Special Asterisk aliases */
#define AST_CAUSE_BUSY          AST_CAUSE_USER_BUSY
#define AST_CAUSE_FAILURE       AST_CAUSE_NETWORK_OUT_OF_ORDER
#define AST_CAUSE_NORMAL        AST_CAUSE_NORMAL_CLEARING
#define AST_CAUSE_NOANSWER      AST_CAUSE_NO_ANSWER
#define AST_CAUSE_CONGESTION    AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
#define AST_CAUSE_UNREGISTERED  AST_CAUSE_SUBSCRIBER_ABSENT
#define AST_CAUSE_NOTDEFINED    0
#define AST_CAUSE_NOSUCHDRIVER  AST_CAUSE_CHAN_NOT_IMPLEMENTED

Redirect

채널을 다른곳으로 redirect(transfer)한다. 즉, 채널 넘겨주기.

Action: Redirect
ActionID: <value>
Channel: <value>
ExtraChannel: <value>
Exten: <value>
ExtraExten: <value>
Context: <value>
ExtraContext: <value>
Priority: <value>
ExtraPriority: <value>
  • Channel - 넘겨주고자 하는 채널.
  • ExtraChannel -추가로 같이 넘겨주고자 하는 채널(optional).
  • Exten - 채널을 넘겨받게 되는 Extension.
  • ExtraExten - ExtraChannel 을 넘겨받게 되는 Extension(optional).
  • Context - 넘겨받게 되는 Context.
  • ExtraContext - ExtraChannel 을 넘겨받게 되는 Context(optional).
  • Priority - 념겨받게 되는 채널의 Priority.
  • ExtraPriority - 넘겨받게 되는 ExtraChannel 의 Priority(optional).

SIP

SIPnotify

Action: SIPnotify
ActionID: <value>
Channel: <value>
Variable: <value>
  • ActionID - ActionID for this transaction. Will be returned.
  • Channel - Peer to receive the notify.
  • Variable - At least one variable pair must be specified. name=value

SIPpeers

현재 등록되어 있는 모든 SIP peer 를 보여준다.

Action: SIPpeers
ActionID: <value>
  • ActionID - ActionID for this transaction. Will be returned.

SIPpeerstatus

Action: SIPpeerstatus
ActionID: <value>
[Peer:] <value>
  • ActionID - ActionID for this transaction. Will be returned.
  • Peer - The peer name you want to check.

SIPqualifypeer

Qualify SIP peers.

Action: SIPqualifypeer
ActionID: <value>
Peer: <value>
  • ActionID - ActionID for this transaction. Will be returned.
  • Peer - The peer name you want to qualify.

SIPshowpeer

Show one SIP peer with details on current status.

Action: SIPshowpeer
ActionID: <value>
Peer: <value>
  • ActionID - ActionID for this transaction. Will be returned.
  • Peer - The peer name you want to check.

Sipshowregistry

현재 등록된 SIP registry 목록을 보여준다.

Action: SIPshowregistry
ActionID: <value>

Example

Action: SIPshowregistry

Response: Success
EventList: start
Message: Registrations will follow

Event: RegistryEntry
Host: 192.168.100.10
Port: 5060
Username: test_register
Domain: 192.168.100.10
DomainPort: 5060
Refresh: 105
State: Request Sent
RegistrationTime: 1447519599

Event: RegistrationsComplete
EventList: Complete
ListItems: 1

Dialplan

DialplanExtensionAdd

Enable since Asterisk-13

Dialplan 에 Extension 을 추가한다.

Action: DialplanExtensionAdd
ActionID: <value>
Context: <value>
Extension: <value>
Priority: <value>
Application: <value>
[ApplicationData:] <value>
[Replace:] <value>
  • ActionID - ActionID for this transaction. Will be returned.
  • Context - Context where the extension will be created. The context will be created if it does not already exist.
  • Extension - Name of the extension that will be created (may include callerid match by separating with '/')
  • Priority - Priority being added to this extension. Must be either hint or a numerical value.
  • Application - The application to use for this extension at the requested priority
  • ApplicationData - Arguments to the application.
  • Replace - If set to 'yes', '1', 'true' or any of the other values we evaluate as true, then if an extension already exists at the requested context, extension, and priority it will be overwritten. Otherwise, the existing extension will remain and the action will fail.

Example

Action: DialplanExtensionAdd
ActionID: 123456
Context: test_dialplan
Extension: test_exten
Priority: 1
Application: echo

Response: Success
ActionID: 123456
Message: Added requested extension

DialplanExtensionRemove

Enable since Asterisk-13

Dialplan 에서 Extension 을 삭제한다.

Action: DialplanExtensionRemove
ActionID: <value>
Context: <value>
Extension: <value>
[Priority:] <value>
  • ActionID - ActionID for this transaction. Will be returned.
  • Context - Context of the extension being removed
  • Extension - Name of the extension being removed (may include callerid match by separating with '/')
  • Priority - If provided, only remove this priority from the extension instead of all priorities in the extension.

Example

Action: DialplanExtensionRemove
ActionID: 999
Context: test_dialplan
Extension: test_exten

Response: Success
ActionID: 999
Message: Removed the requested extension

ETC

See also

References

<references />