Show active calls for a specific inbound route number

Hi All,

Does anyone have an idea how I can see if there is an active call ongoing for a specific inbound route number (DID)?
Ideally I would need a CLI command :)…

Thanks for your help!

start with

rasterisk -x 'core show channels verbose' | grep NUMBER

I am embarrassed to ask because in all my years I never knew/realized that rasterisk was a thing and now I am confused and curios to know. Why does this symlink of rasterisk to asterisk exist?

To save a little bit of time? :smiley:

1 Like

as @jcolp said, tab completion in a shell, originally it was a separate binary r(emote)asterisk, I believe without ascii color in the terminal,

Alright, I really want to know how. I 100% know that I am missing some historical context here for it but I am genuinely curious about that context.

That context is lost to time. It’s from over 20 years ago.

…and predates review of commit messages, and standards

and is a muscle memory of my 4-finger typing over a serially connected terminal or a dsl line

Ha alright, a mystery that shall never be answered!

Thanks for the suggestion, but this is not really what I’m looking for.
The output of the command is showing the calling number, not the number which is being called (DID).

How can I see if there is an active call ongoing for a specific inbound route number (DID)?

You used to find this in a lot on Unix/Linux utilities. The extreme case is probably busybox, which is or was used for OS installers and systems on a floppy.

The command name is parameter 0, so a command can use this to select a mode just as much as -r is used to do that.

(busybox implements most of the core linux commands in a single executable.)

I think the only way you could do it is by tracking the call, using AMI or CEL events, or by maintaining a database from custom dialplan, and using hangup handlers, to remove entries at the end of a call, and clearing the table during startup.

The number might be available in dialplan variables, but you’d have to do a lot of work, if you didn’t track events, to enumerate all the open channels and read their variables.

As Asterisk is a B2BUA you should see two legs in core show channels after the call is connected, so eliminate the grep pipe to see what you have available, you might need to otherwise derive the extension that answered from the DID inbound route, they will have the same channel

When I only use the core show channels command… I don’t see any DID number(s), only internal extensions and queue numbers.

Thanks @david55 ! Will think about it :slight_smile:

This is more convoluted than it needs to be. This can all be handled by the GROUP() function in Asterisk. In FreePBX terms it means doing the following:

  1. In extensions_custom.conf write a context for counting the calls. the ${FROM_DID} variable holds the called DID that was matched by an inbound route. Also, remember that inbound routes don’t have to match on the called DID but can match against the calling CID. A single inbound route may also match against a pattern for the called DID or even the calling CID.
exten = s,1,Noop(Inbound Call Counter: There are currently ${GROUP_COUNT(${FROM_DID})} calls for ${FROM_DID})
exten = s,n,Set(GROUP(${FROM_DID})=${FROM_DID}))
exten = s,n,Goto(ivr-1,s,1) ; add the final destination of the route, such as IVR or extension. Will need to know the context,exten,priority you are sending to.
  1. Go into Custom Destinations and create a new destination. For the Target you put: inbound-counter,s,1

  2. In the Inbound Route you set the destination to Custom Destination and then select the custom destination you made.

Now you are tracking inbound calls by the called DID. The downside is, as pointed out, you need to know the true context,exten,priority syntax to get the calls to the right destination after the counters are hit.

I agree group counts can do it if you only need to know of the existence. On re-reading, I see that the actual requirement only required that, although the subject implied a detailed list.

Getting there using this (very smart) approach. Do you by any chance know if it’s possible to fetch the ${GROUP_COUNT(${FROM_DID})} using the AMI?

There’s no AMI action for GROUP or GROUP_COUNT because at that point you can be listening for AMI events and get the count other ways. The only way to use AMI for this is to store the count in the AstDB and use DBGet action to get the current value stored in the AstDB.