Summary:ASTERISK-03598: [patch] show extension <exten>
Reporter:Clod Patry (junky)Labels:
Date Opened:2005-02-27 12:55:13.000-0600Date Closed:2011-06-07 14:05:05
Versions:Frequency of
Environment:Attachments:( 0) show_exten_rev1.diff.txt
Description:This is really helpful if we have a lot of active channels and we want to know how many channels are created for that specific extension.


This works like that:
asterisk*CLI> show extension 5145553396
Extension 5145553396 is currently used on 2 channel(s)

In a real world context:
gate2*CLI> show channels
       Channel  (Context    Extension    Pri )   State Appl.         Data
      Zap/92-1  (from_dialogic s            1   )      Up Bridged Call  Zap/5-1
       Zap/5-1  (from_bell  7777         2   )      Up Dial          Zap/r3/7777
    Zap/0:65-1  (from_dialogic s            1   )      Up Bridged Call  Zap/23-1
      Zap/23-1  (from_bell  5506         2   )      Up Dial          Zap/g3/5506
     Zap/119-1  (from_bell  s            1   )      Up Bridged Call  Zap/121-1
     Zap/121-1  (from_dialogic 5551234  2   )      Up Dial          Zap/G1/5551234
     Zap/118-1  (from_bell  s            1   )      Up Bridged Call  Zap/122-1
     Zap/122-1  (from_dialogic 5551234 2   )      Up Dial          Zap/G1/5551234
    Zap/0:66-1  (from_dialogic s            1   )      Up Bridged Call  Zap/12-1
      Zap/12-1  (from_bell  7111         2   )      Up Dial          Zap/g3/7111
      Zap/91-1  (from_dialogic s            1   )      Up Bridged Call  Zap/19-1
      Zap/19-1  (from_bell  7777         2   )      Up Dial          Zap/r3/7777
    Zap/0:68-1  (from_dialogic s            1   )      Up Bridged Call  Zap/10-1
      Zap/10-1  (from_bell  1879         2   )      Up Dial          Zap/g3/1879
    Zap/0:69-1  (from_dialogic s            1   )      Up Bridged Call  Zap/18-1
      Zap/18-1  (from_bell  9811         2   )      Up Dial          Zap/g3/9811
     Zap/143-1  (from_dialogic s            1   )      Up Bridged Call  Zap/2-1
       Zap/2-1  (from_bell  5540         2   )      Up Dial          Zap/G3/5540
     Zap/170-1  (to_ras     s            1   )      Up Bridged Call  Zap/21-1
      Zap/21-1  (from_bell  5480         11  )      Up Dial          Zap/g8/5480
20 active channel(s)

It's hard to say how many users have called to extension 7777 without counting them by hand.
This will can be done with a simple:
> show extension 7777.

And a great thanks to hermie for the suggestion to add a filter by context.

so Usage is like:
show extension <exten>[@<context>]

Omitting the @context part will do a show extension for all contexts and for that specific exten.

Disclaimer on file.
Comments:By: Tilghman Lesher (tilghman) 2005-02-27 13:22:29.000-0600

This seems like more of an "inuse" type of command -- "show extension <n>" seems like it should be similar to the functionality of "show dialplan <n>@context".

It's a great idea to filter the "show channels" output, but maybe your command should be renamed to avoid confusion.  Perhaps a better syntax might be "show channels matching 5145553396"

By: Clod Patry (junky) 2005-02-27 14:07:00.000-0600

like anthm suggested it, show channels like <foo>.
the reason why i didnt take it, i think show channels like exten@context is unclear.

show extension would be really clear.

Also, i've the goal to do a show extensions [context]
which will display the total number of users per extension, which will display something like:
exten     total
7777      3
9966      7

and so on.

And maybe we can say that into the documentation, show dialplan is for all extensions (active or not), while the show extension(s) would be for actives channels only. What do you think about it?

By: Olle Johansson (oej) 2005-02-27 14:09:02.000-0600

"show extension" is not a good name, too confusing. I agree with anthm.

Adding a filter to "show channels" with the same syntax as we use in "sip show peers" with regexps will be a good addition.

By: Kevin P. Fleming (kpfleming) 2005-02-27 15:34:20.000-0600

I'll add my voice to this as well: "show extension" sounds like it displaying static dialplan information in my mind, not in-use information.

How about "show channels in {extension}[@context]"? You can't just use a simple filter without a 'tag', because that would filter on the channel names. This syntax would directly indicate that you want channels that are currently _in_ that extension.

By: Mark Spencer (markster) 2005-02-27 18:15:49.000-0600

I agree with kpfleming's suggested syntax, and that this should be a slight mod to  show_channels.

By: Clod Patry (junky) 2005-02-27 19:46:39.000-0600

im okay with show channels IN {extension}[@context]. The only troubles i see related to that, is how we'll display all total of users by extensions for all channels actives?

show channels IN extensions ? show channels IN ALL ?
i'd like to see a feature by a specific extension and for for all extensions.
any suggestions for that?

By: Tilghman Lesher (tilghman) 2005-02-27 23:08:35.000-0600

Perhaps you're looking for a syntax like:

show inuse for <extension>

That's definitely more clear.

By: Kevin P. Fleming (kpfleming) 2005-02-28 00:02:35.000-0600

Yep, Corydon's got it... the reason you can't find a good way to show the totals using "show channels in ..." is because that's a different function :-)

If this second function is only going to show totals (grouped by extension/context) and not actually list channels, I'd vote for:

channel count extension {extension}[@context]]

I know this isn't "show channels", but most of the rest of Asterisk seems to moving to the 'module name'-'verb'-'item' syntax, so it would make a small bit of sense to start moving the core over to that as well :-)

By: Mark Spencer (markster) 2005-02-28 00:11:57.000-0600

I think this could be a pretty small mod to the existing show_channels so that the format and information is identical (i.e. not just the sum but the list of channels).  What do you think?

By: Clod Patry (junky) 2005-02-28 06:16:10.000-0600

The problem is the displaying of all extensions.
How you would display all that with the current format syntax?

at the beginning, my show extensions was something like:
extension    context    total
7777         default    3
7532         from_bell  13
3333         from_bell  2

the whole idea behind this, is just to know how many users have called a specific extension.  Is there any need to display all channels informations with this patch? I don't think so, cause its just a way to get rapid sums(s).

and based on the latest cory's idea, show inuse could do that and show inuse for <exten>@context would do for a specific extension?

and what about show channels extensions for all extensions
and show channels <exten>[@context] for a specific extension?

edited on: 02-28-05 06:25

By: Kevin P. Fleming (kpfleming) 2005-02-28 09:36:30.000-0600

No, 'show channels <foo>' (if it existed) would always be based on the channel's name, not any other details. That's why you need to use 'show channels in <foo>' to make sure that there is no conflict.

By: Clod Patry (junky) 2005-03-10 21:10:21.000-0600

and to get like a summary of all sums of alls extensions?

show channels IN ALL ?
and for a specific extension sum: show channels IN 7777 ?

By: Kevin P. Fleming (kpfleming) 2005-03-10 21:53:12.000-0600

I'm not thrilled by either of those, because they are not "showing channels", they are counting channels.

Maybe a compromise:

show channels [[summary] in [extension[@context]]]

Adding 'summary' would stop the command from actually listing channels, and only provide counts by found extensions (if the extension supplied is a pattern match, not a single extension). Pattern matching should be done using regex, like 'sip show peers' does, on the extension and context separately.

By: Clod Patry (junky) 2005-03-10 22:28:48.000-0600

i was not thinking about regex, just a completion after the IN <tab> would display all the current active extensions.

about summary, i think it's a good idea, its at the same level of the "concise", and it's clear too.

At the beginning, i thought show extensions, it was reject cause its only the active channels. Maybe show active extensions for all sums, and show active extension <foobar> gives the sum only for foobar?

By: Mark Spencer (markster) 2005-03-26 18:17:54.000-0600

Is this going anywhere?

By: Clod Patry (junky) 2005-03-27 10:02:15.000-0600

I'll suspend it for a bit, i dont have any time to work on that one.