How to count the number of concurrent calls on a trunk

The Article describes how to see the number of concurrent calls on a trunk by adding a tag so it is recorded in CDR-View.

Created: March 2020

Permalink: https://wildix.atlassian.net/wiki/x/yQDOAQ

Introduction

There might be a scenario where someone needs to know the  number of concurrent calls over a trunk. This can sometimes be important in terms of capacity planning, example; for billing purposes or just to limit/control how many concurrent calls are placed on a trunk.

This custom application can be used to provide this data in CDR-View on a call by call basis.  And of course, CDR-View could then be used to pull records for a specific time frame or filter, then sort by the tag field and locate the maximum number for the “concurrent calls” tag.

Prerequisites

There are 2 applications that are needed in order to be able to count concurrent calls, please read carefully each one.

  • GROUP

Every call in PBX engine is a channel.  Although PBX engine could be using just 1 trunk or 10, at the end of the day, everything will be channels from its perspective.  So in order to be able to track concurrent calls over a specific trunk, first we need to mark or tag the channel so later it can be counted.  This is the purpose of GROUP.

  • GROUP_COUNT

Once our channels are marked (Grouped), all we have to do is count them.  That is the purpose of GROUP_COUNT application.

Dialplan Configuration

Outbound calls

As mentioned, two applications need to be used to count channels.  Probably the easiest way to do this is in the Dialplan entries that “Dial the trunk”.  Let's assume you have an entry in your  Dialplan to dial National numbers in the USA. So, for example, 1 followed by 10 digits.  With the following Dialplan you can count all concurrent calls that dialed a national number: 


  1. Custom application -> Set(GROUP()=TrunkOUT) - here we are marking this channel (call) with the label “TrunkOut”.  This is simply done so that we can then use the Group Count application next
  2. Set -> Tags -> calls:${GROUP_COUNT(TrunkOUT)} -  here we are setting a Tag (so you can see the result in cdrview) with the concurrent calls count.  For this, we use the function “${GROUP_COUNT(TrunkOUT)}”. Please notice that we pass as argument to this application which is the label “TrunkOUT”.  What this will do is check all active channels (active calls) and count those marked as “TrunkOUT”. Thus it produces a count of concurrent calls that are “grouped” into the TrunkOUT group
  3. Dial the trunk -> select a trunk - just dial the trunk as you would normally do.

Once the 2 mentioned applications are added to the Dialplan, the following is what you will see in CDR-View: 


In the previous picture, the first 3 calls were concurrent (all 3 were active at the same time).  And you can see in the tags that every new call made increased the count.

In this example Dialplan, it will ONLY count national calls.  But of course you can choose to count all calls, international calls separately, or whatever you’d like.  You simply need to use the Set Group methodology for the group of calls that you're interested in.

Inbound calls

For inbound calls we also need to use the above mentioned applications.  Most likely the best place to put such applications is in your "main" Dialplan procedure (default Dialplan for inbound calls).  So, let's assume that your trunk has 10 DIDs and that you want to count ALL incoming calls. You would need to put something like the following in every DID entry: 


  1. Custom application -> Set(GROUP()=TrunkIN) - here we are marking this channel (call) with the label “TrunkIN”
  2. Set -> Tags -> calls:${GROUP_COUNT(TrunkIN)} - here we are setting a Tag (so you can see the result in cdrview) with the concurrent calls count. For that we use the function “${GROUP_COUNT(TrunkIN)}”
  3. Dial the phone -> Number 108 - Just dial the phone (or anything you wish to do for this DID) as you would normally do.

So as you can see, the solution is the same for inbound calls as it is for outbound calls.  It’s just a matter of marking the correct call with a specific and unique group.

Once the 2 mentioned applications are added to the dial plan for inbound calls, the following is what you will see in CDR-View: 


In the previous picture, the first 3 calls were concurrent (all 3 were active at the same time) and you can see in tags that every new incoming call made increased the count.

All calls (total concurrent calls)

In the Dialplans below, inbound and outbound calls are all grouped together.  This results in a tag that will tell you a total concurrent count on the trunk being used.  You see that this is accomplished simply by using the same label in both inbound and outbound calls. So for instance, just use Trunk instead of TrunkOUT and TrunkIN.  Example below:



When the same label is used for both inbound and outbound calls, CDR-View will look like this: 


In the previous picture only the first 2 calls are inbound and the third one was outbound. Notice however that all 3 of them were active concurrently and  were counted together.

Notes

When assigning a label to channels, please make sure the label is not used anywhere else (Call group names, Trunk names, Dialplans names  and so on). Otherwise, it could lead to incorrect counting.