Count and limit number of calls under asterisk

Under asterisk, from your dialplan or an agi script you canput your calls (that has the same purpose)

in the same group.

This can be done using the GROUP* functions under asterisk.

- With GROUP() you can retrieve or set a group for the current channel

- With GROUP_COUNT() you can retrieve the total of live channel in that group

- With GROUP_LIST, you will get a list of group where the current channel is. So you can set put the same channel in multiple group to classify them.

- With GROUP_MATCH_COUNT, you can retrieve the number of live channels in that group matching the specifed regular expression.

Example :

A nice application for this is, if you have multiple inbound DIDs that reach a same T1 or E1 and want to limit calls to DID 2120000000 to 15 for example. Your dialplan should go like this :

exten => 212000000,1,Noop(Received call to extension ${EXTEN})

exten => 212000000,n,GROUP(${EXTEN}) ; send all calls coming here to group 2120000000

exten => 2120000000,n,GotoIf($[ ${GROUP_COUNT()} > 15 ]?maxreached) ; make your check

exten => 2120000000,n, ……. ; Normal call flow

exten => 2120000000,n,Hangup

exten => 2120000000,n(maxreached),Congestion ; Here there is too many calls - You could play a message as well

exten => 2120000000,n,Busy

Help on functions

[Syntax]
GROUP([category])
[Synopsis]
Gets or sets the channel group.
[Description]
Gets or sets the channel group.

[Syntax]
GROUP_COUNT([groupname][@category])
[Synopsis]
Counts the number of channels in the specified group
[Description]
Calculates the group count for the specified group, or uses the
channel’s current group if not specifed (and non-empty).

[Syntax]
GROUP_MATCH_COUNT(groupmatch[@category])
[Synopsis]
Counts the number of channels in the groups matching the specified pattern
[Description]
Calculates the group count for all groups that match the specified pattern.
Uses standard regular expression matching (see regex(7)).

[Syntax]
GROUP_LIST()
[Synopsis]
Gets a list of the groups set on a channel.
[Description]
Gets a list of the groups set on a channel.

Comments

Leave a Reply