[asterisk-users] Counting calls in progress from AMI

Aldo Bergamini aaberga at gmail.com
Thu Oct 18 10:53:52 CDT 2012


On 18 Oct 2012, at 17:19, Michelle Dupuis wrote:

> I need to do this from the AMI (not the CLI)...I don't *think* a comparable command exists from the AMI.
>  
> As well, I don't want to poll the system for calls so I'm hoping to trap a call bridged,unbridged type event.
>  


Michelle,

if you do not want to poll Asterisk with an AMI 'Status' event (that returns a list of open channels) counting the bridged, unbridged events is possible, but not that easy..

There are two gotchas around this:

One is that a single call, depending of what the dialplan is doing, can involve several bridged, unbridged events;
	
The second is that some kind of calls (I call them 'one legged calls': anything resembling an IVR or a call to get voicemail) do not get any bridged, unbridged events, at all. The same applies for calls that are sent to a MeetMe conference: there you see specific MeetMe events for conference rooms.

If you have access to the dialplan (that is if you are in charge of it and you can modify it) you could add some user defined events, to mark the 'rising' of a call and its connection to the far side. The dialplan can send pretty much what you like by using UserEvent.

As an example:

exten => _00.,n,UserEvent(DNIS-Ext,Exten: ${EXTEN},CallerID: "${CALLERID(num)}",DNID: "${CALLERID(dnid)}",DisplayID: "${PersonalID_Num}",ChannelID: "${CHANNEL}",RDNIS: "${RDNIS}")


The first string (DNIS-Ext) is a marker: anything that you want to receive that 'brands' the user event to your suiting.

The rest is a list of (name, value) pairs, giving the details you might need on the AMI processing side.

Beware of any loop in the dialplan: it might be that you will get multiple copies of the same event, if the dialplan execution is such that the same extension is visited more than once during the processing of a call.


HTH,
Aldo




More information about the asterisk-users mailing list