how to know channel name ?

Home » Asterisk Users » how to know channel name ?
Asterisk Users 15 Comments

Hello list,

to use ChanSpy, one needs to know the name of the channel.

But on an incoming call from the provider, or an outgoing call to the
provider there are always numbers added. How can one then know the
channel name ??

/core show channels verbose/ shows me for example :

/SIP/*378680644-00002* default
SIP/*rs4-00002445* sub-uitinternation
SIP/*3715320168-00002* default
SIP*/ibenla2-0000244* sub-uit789
SIP/*372083610-00002* default
SIP/*cedhou0-000024* sub-uit789
SIP*/travel3-00002* pbx-routing
SIP/*INTELin-00002* pbx-routing
SIP/*375382280-00002* default
SIP/*miq8-00002419* sub-uitGSM
SIP/*3749378004-0000* default
SIP*/instlpr0-00002* sub-uitinternation
SIP/*372089170-00002* default
SIP/*v9q9uLT-0000* from-GFATRUNK
46 active channels
24 active calls/

If I want to listen to the conversation of /SIP/*miq8-00002419*/and
/SIP/*375382280-00002*/(these 2 channels have been connected to 1
conversation), how do I use ChanSpy ??

15 thoughts on - how to know channel name ?

  • Strip off the -xxxxx. Just listen to SIP/miq8 and SIP/375382280 in your
    example.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 7:47 AM

    Hello list,

    to use ChanSpy, one needs to know the name of the channel.

    But on an incoming call from the provider, or an outgoing call to the
    provider there are always numbers added. How can one then know the channel
    name ??

    core show channels verbose shows me for example :

    SIP/378680644-00002 default
    SIP/rs4-00002445 sub-uitinternation
    SIP/3715320168-00002 default
    SIP/ibenla2-0000244 sub-uit789
    SIP/372083610-00002 default
    SIP/cedhou0-000024 sub-uit789
    SIP/travel3-00002 pbx-routing
    SIP/INTELin-00002 pbx-routing
    SIP/375382280-00002 default
    SIP/miq8-00002419 sub-uitGSM
    SIP/3749378004-0000 default
    SIP/instlpr0-00002 sub-uitinternation
    SIP/372089170-00002 default
    SIP/v9q9uLT-0000 from-GFATRUNK
    46 active channels
    24 active calls

    If I want to listen to the conversation of SIP/miq8-00002419 and
    SIP/375382280-00002 (these 2 channels have been connected to 1
    conversation), how do I use ChanSpy ??

  • Hello,

    OK thanks. But, I want to listen to the conversation (not just 1 channel
    out of 2 channels). How then do I use ChanSpy ?

  • I would try chanspy(sip/miq8,b) – the b flag denotes to only listen to a
    bridged call which (it seems to me) should pick up both sides.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 8:46 AM

    Hello,

    OK thanks. But, I want to listen to the conversation (not just 1 channel out
    of 2 channels). How then do I use ChanSpy ?

    Strip off the -xxxxx. Just listen to SIP/miq8 and SIP/375382280 in your
    example.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 7:47 AM

    Hello list,

    to use ChanSpy, one needs to know the name of the channel.

    But on an incoming call from the provider, or an outgoing call to the
    provider there are always numbers added. How can one then know the channel
    name ??

    core show channels verbose shows me for example :

    SIP/378680644-00002 default
    SIP/rs4-00002445 sub-uitinternation
    SIP/3715320168-00002 default
    SIP/ibenla2-0000244 sub-uit789
    SIP/372083610-00002 default
    SIP/cedhou0-000024 sub-uit789
    SIP/travel3-00002 pbx-routing
    SIP/INTELin-00002 pbx-routing
    SIP/375382280-00002 default
    SIP/miq8-00002419 sub-uitGSM
    SIP/3749378004-0000 default
    SIP/instlpr0-00002 sub-uitinternation
    SIP/372089170-00002 default
    SIP/v9q9uLT-0000 from-GFATRUNK
    46 active channels
    24 active calls

    If I want to listen to the conversation of SIP/miq8-00002419 and
    SIP/375382280-00002 (these 2 channels have been connected to 1
    conversation), how do I use ChanSpy ??

  • Hello,

    thanks. miq8 is the name of the SIP peer account.

    So when I know the SIP peer name, and I strip of the numbers of the
    channel, then I can use ChanSpy. So this answers my original question.

    The only problem I see : it is Asterisk that gives the channel its name.
    How do I change this ??

    As far as I know, Asterisk randomly gives a channel name which consists
    of the technology (SIP), the peername (miq8) and some numbers…

    How to change the channel name ?

  • It’s not random. The “Channel Name” is Tech/peer-sequence (sequence is in
    hex). You can control (to a degree) the peer portion in
    sip.conf/users.conf.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:07 AM

    Hello,

    thanks. miq8 is the name of the SIP peer account.

    So when I know the SIP peer name, and I strip of the numbers of the channel,
    then I can use ChanSpy. So this answers my original question.

    The only problem I see : it is Asterisk that gives the channel its name. How
    do I change this ??

    As far as I know, Asterisk randomly gives a channel name which consists of
    the technology (SIP), the peername (miq8) and some numbers…

    How to change the channel name ?

    I would try chanspy(sip/miq8,b) – the b flag denotes to only listen to a
    bridged call which (it seems to me) should pick up both sides.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 8:46 AM

    Hello,

    OK thanks. But, I want to listen to the conversation (not just 1 channel out
    of 2 channels). How then do I use ChanSpy ?

    Strip off the -xxxxx. Just listen to SIP/miq8 and SIP/375382280 in your
    example.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 7:47 AM

    Hello list,

    to use ChanSpy, one needs to know the name of the channel.

    But on an incoming call from the provider, or an outgoing call to the
    provider there are always numbers added. How can one then know the channel
    name ??

    core show channels verbose shows me for example :

    SIP/378680644-00002 default
    SIP/rs4-00002445 sub-uitinternation
    SIP/3715320168-00002 default
    SIP/ibenla2-0000244 sub-uit789
    SIP/372083610-00002 default
    SIP/cedhou0-000024 sub-uit789
    SIP/travel3-00002 pbx-routing
    SIP/INTELin-00002 pbx-routing
    SIP/375382280-00002 default
    SIP/miq8-00002419 sub-uitGSM
    SIP/3749378004-0000 default
    SIP/instlpr0-00002 sub-uitinternation
    SIP/372089170-00002 default
    SIP/v9q9uLT-0000 from-GFATRUNK
    46 active channels
    24 active calls

    If I want to listen to the conversation of SIP/miq8-00002419 and
    SIP/375382280-00002 (these 2 channels have been connected to 1
    conversation), how do I use ChanSpy ??

  • Of course I can control the name of my SIP-peer. Why do you tell me this ?!

    Please answer my question : how do I know the channel name so I can
    ChanSpy the correct channel ?

  • You are either going to be able to listen to SIP/miq8 or you are going to
    have to know the sequence number like SIP/miq8-00001. Maybe you should just
    use ExtenSpy instead?

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:26 AM

    Of course I can control the name of my SIP-peer. Why do you tell me this ?!

    Please answer my question : how do I know the channel name so I can ChanSpy
    the correct channel ?

    It’s not random. The “Channel Name” is Tech/peer-sequence (sequence is in
    hex). You can control (to a degree) the peer portion in
    sip.conf/users.conf.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:07 AM

    Hello,

    thanks. miq8 is the name of the SIP peer account.

    So when I know the SIP peer name, and I strip of the numbers of the channel,
    then I can use ChanSpy. So this answers my original question.

    The only problem I see : it is Asterisk that gives the channel its name. How
    do I change this ??

    As far as I know, Asterisk randomly gives a channel name which consists of
    the technology (SIP), the peername (miq8) and some numbers…

    How to change the channel name ?

    I would try chanspy(sip/miq8,b) – the b flag denotes to only listen to a
    bridged call which (it seems to me) should pick up both sides.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 8:46 AM

    Hello,

    OK thanks. But, I want to listen to the conversation (not just 1 channel out
    of 2 channels). How then do I use ChanSpy ?

    Strip off the -xxxxx. Just listen to SIP/miq8 and SIP/375382280 in your
    example.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 7:47 AM

    Hello list,

    to use ChanSpy, one needs to know the name of the channel.

    But on an incoming call from the provider, or an outgoing call to the
    provider there are always numbers added. How can one then know the channel
    name ??

    core show channels verbose shows me for example :

    SIP/378680644-00002 default
    SIP/rs4-00002445 sub-uitinternation
    SIP/3715320168-00002 default
    SIP/ibenla2-0000244 sub-uit789
    SIP/372083610-00002 default
    SIP/cedhou0-000024 sub-uit789
    SIP/travel3-00002 pbx-routing
    SIP/INTELin-00002 pbx-routing
    SIP/375382280-00002 default
    SIP/miq8-00002419 sub-uitGSM
    SIP/3749378004-0000 default
    SIP/instlpr0-00002 sub-uitinternation
    SIP/372089170-00002 default
    SIP/v9q9uLT-0000 from-GFATRUNK
    46 active channels
    24 active calls

    If I want to listen to the conversation of SIP/miq8-00002419 and
    SIP/375382280-00002 (these 2 channels have been connected to 1
    conversation), how do I use ChanSpy ??

  • Hello,

    how to use ExtenSpy(extension@context) when conversations are named like
    this ? :

    /SIP/*378680644-00002* default
    SIP/*rs4-00002445* sub-uitinternation
    SIP/*3715320168-00002* default
    SIP*/ibenla2-0000244* sub-uit789
    SIP/*372083610-00002* default
    SIP/*cedhou0-000024* sub-uit789
    SIP*/travel3-00002* pbx-routing
    SIP/*INTELin-00002* pbx-routing
    SIP/*375382280-00002* default
    SIP/*miq8-00002419* sub-uitGSM
    SIP/*3749378004-0000* default
    SIP*/instlpr0-00002* sub-uitinternation
    /
    Can you tell me what is the extension ? How will I know the context ?
    The context is not always the same…

  • Extenspy(miq8@default) for miq8. I would either proceed under the
    assumption that I’m going to be listening to my extensions in the default
    context or set up an AGI or something to load my needed ext@context
    information.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:41 AM

    Hello,

    how to use ExtenSpy(extension@context) when conversations are named like
    this ? :

    SIP/378680644-00002 default
    SIP/rs4-00002445 sub-uitinternation
    SIP/3715320168-00002 default
    SIP/ibenla2-0000244 sub-uit789
    SIP/372083610-00002 default
    SIP/cedhou0-000024 sub-uit789
    SIP/travel3-00002 pbx-routing
    SIP/INTELin-00002 pbx-routing
    SIP/375382280-00002 default
    SIP/miq8-00002419 sub-uitGSM
    SIP/3749378004-0000 default
    SIP/instlpr0-00002 sub-uitinternation

    Can you tell me what is the extension ? How will I know the context ? The
    context is not always the same…

    You are either going to be able to listen to SIP/miq8 or you are going to
    have to know the sequence number like SIP/miq8-00001. Maybe you should just
    use ExtenSpy instead?

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:26 AM

    Of course I can control the name of my SIP-peer. Why do you tell me this ?!

    Please answer my question : how do I know the channel name so I can ChanSpy
    the correct channel ?

    It’s not random. The “Channel Name” is Tech/peer-sequence (sequence is in
    hex). You can control (to a degree) the peer portion in
    sip.conf/users.conf.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:07 AM

    Hello,

    thanks. miq8 is the name of the SIP peer account.

    So when I know the SIP peer name, and I strip of the numbers of the channel,
    then I can use ChanSpy. So this answers my original question.

    The only problem I see : it is Asterisk that gives the channel its name. How
    do I change this ??

    As far as I know, Asterisk randomly gives a channel name which consists of
    the technology (SIP), the peername (miq8) and some numbers…

    How to change the channel name ?

    I would try chanspy(sip/miq8,b) – the b flag denotes to only listen to a
    bridged call which (it seems to me) should pick up both sides.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 8:46 AM

    Hello,

    OK thanks. But, I want to listen to the conversation (not just 1 channel out
    of 2 channels). How then do I use ChanSpy ?

    Strip off the -xxxxx. Just listen to SIP/miq8 and SIP/375382280 in your
    example.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 7:47 AM

    Hello list,

    to use ChanSpy, one needs to know the name of the channel.

    But on an incoming call from the provider, or an outgoing call to the
    provider there are always numbers added. How can one then know the channel
    name ??

    core show channels verbose shows me for example :

    SIP/378680644-00002 default
    SIP/rs4-00002445 sub-uitinternation
    SIP/3715320168-00002 default
    SIP/ibenla2-0000244 sub-uit789
    SIP/372083610-00002 default
    SIP/cedhou0-000024 sub-uit789
    SIP/travel3-00002 pbx-routing
    SIP/INTELin-00002 pbx-routing
    SIP/375382280-00002 default
    SIP/miq8-00002419 sub-uitGSM
    SIP/3749378004-0000 default
    SIP/instlpr0-00002 sub-uitinternation
    SIP/372089170-00002 default
    SIP/v9q9uLT-0000 from-GFATRUNK
    46 active channels
    24 active calls

    If I want to listen to the conversation of SIP/miq8-00002419 and
    SIP/375382280-00002 (these 2 channels have been connected to 1
    conversation), how do I use ChanSpy ??

  • Hello,

    there is very little information about the function CHANNELS().

    If I know the peer name (that I always know for sure), do you see a way
    of using the function CHANNELS() to get the right channel ??

    If CHANNELS() gives a “space-delimited” list of active channels, and I
    know miq8… how can I get /SIP/miq8-00002419/ ?

    Thanks !

  • Did a little research on this using my Asterisk 10.0. This should work for
    you.

    exten => 1246,1,answer()

    exten => 1246,n,set(inuse=${CHANNELS(miq8)})

    exten => 1246,n,extenspy(${inuse}@default)

    exten => 1246,n,hangup()

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:52 AM

    Hello,

    there is very little information about the function CHANNELS().

    If I know the peer name (that I always know for sure), do you see a way of
    using the function CHANNELS() to get the right channel ??

    If CHANNELS() gives a “space-delimited” list of active channels, and I know
    miq8… how can I get SIP/miq8-00002419 ?

    Thanks !

    Extenspy(miq8@default) for miq8. I would either proceed under the
    assumption that I’m going to be listening to my extensions in the default
    context or set up an AGI or something to load my needed ext@context
    information.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:41 AM

    Hello,

    how to use ExtenSpy(extension@context) when conversations are named like
    this ? :

    SIP/378680644-00002 default
    SIP/rs4-00002445 sub-uitinternation
    SIP/3715320168-00002 default
    SIP/ibenla2-0000244 sub-uit789
    SIP/372083610-00002 default
    SIP/cedhou0-000024 sub-uit789
    SIP/travel3-00002 pbx-routing
    SIP/INTELin-00002 pbx-routing
    SIP/375382280-00002 default
    SIP/miq8-00002419 sub-uitGSM
    SIP/3749378004-0000 default
    SIP/instlpr0-00002 sub-uitinternation

    Can you tell me what is the extension ? How will I know the context ? The
    context is not always the same…

    You are either going to be able to listen to SIP/miq8 or you are going to
    have to know the sequence number like SIP/miq8-00001. Maybe you should just
    use ExtenSpy instead?

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:26 AM

    Of course I can control the name of my SIP-peer. Why do you tell me this ?!

    Please answer my question : how do I know the channel name so I can ChanSpy
    the correct channel ?

    It’s not random. The “Channel Name” is Tech/peer-sequence (sequence is in
    hex). You can control (to a degree) the peer portion in
    sip.conf/users.conf.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:07 AM

    Hello,

    thanks. miq8 is the name of the SIP peer account.

    So when I know the SIP peer name, and I strip of the numbers of the channel,
    then I can use ChanSpy. So this answers my original question.

    The only problem I see : it is Asterisk that gives the channel its name. How
    do I change this ??

    As far as I know, Asterisk randomly gives a channel name which consists of
    the technology (SIP), the peername (miq8) and some numbers…

    How to change the channel name ?

    I would try chanspy(sip/miq8,b) – the b flag denotes to only listen to a
    bridged call which (it seems to me) should pick up both sides.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 8:46 AM

    Hello,

    OK thanks. But, I want to listen to the conversation (not just 1 channel out
    of 2 channels). How then do I use ChanSpy ?

    Strip off the -xxxxx. Just listen to SIP/miq8 and SIP/375382280 in your
    example.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 7:47 AM

    Hello list,

    to use ChanSpy, one needs to know the name of the channel.

    But on an incoming call from the provider, or an outgoing call to the
    provider there are always numbers added. How can one then know the channel
    name ??

    core show channels verbose shows me for example :

    SIP/378680644-00002 default
    SIP/rs4-00002445 sub-uitinternation
    SIP/3715320168-00002 default
    SIP/ibenla2-0000244 sub-uit789
    SIP/372083610-00002 default
    SIP/cedhou0-000024 sub-uit789
    SIP/travel3-00002 pbx-routing
    SIP/INTELin-00002 pbx-routing
    SIP/375382280-00002 default
    SIP/miq8-00002419 sub-uitGSM
    SIP/3749378004-0000 default
    SIP/instlpr0-00002 sub-uitinternation
    SIP/372089170-00002 default
    SIP/v9q9uLT-0000 from-GFATRUNK
    46 active channels
    24 active calls

    If I want to listen to the conversation of SIP/miq8-00002419 and
    SIP/375382280-00002 (these 2 channels have been connected to 1
    conversation), how do I use ChanSpy ??

  • This could work, yes.

    But the context is not always the same.

    Also ${CHANNELS(miq8) will return nothing…

    Jonas.

  • I use ChanSpy successfully all the time. You do not have to specify the
    full channel, just the prefix which is the peer name. As you can see it
    also states ‘This includes the audio coming in and out of the channel
    being spied on.’

    Have you tried giving it a go?

    -= Info about application ‘ChanSpy’ =-

    [Synopsis]
    Listen to a channel, and optionally whisper into it.

    [Description]
    This application is used to listen to the audio from an Asterisk
    channel.
    This includes the audio coming in and out of the channel being spied
    on.
    If the ‘chanprefix’ parameter is specified, only channels beginning with
    this
    string will be spied upon.
    While spying, the following actions may be performed:
    – Dialing ‘#’ cycles the volume level.
    append
    to ‘chanprefix’. For example, executing ChanSpy(Agent) and then dialing
    the
    digits ‘1234#’ while spying will begin spying on the channel
    ‘Agent/1234’.
    Note that this feature will be overridden if the ‘d’ option is used
    NOTE: The option supersedes the three features above in that if a
    valid
    single digit extension exists in the correct context ChanSpy will exit
    to
    it. This also disables choosing a channel based on ‘chanprefix’ and a
    digit
    sequence.

    [Syntax]
    ChanSpy([chanprefix][,options])

    [Arguments]
    options
    b: Only spy on channels involved in a bridged call.

    B: Instead of whispering on a single channel barge in on both
    channels
    involved in the call.

    c(digit):
    digit – Specify a DTMF digit that can be used to spy on the
    next available channel.

    d: Override the typical numeric DTMF functionality and instead use
    DTMF to switch between spy modes.
    4 – spy mode
    5 – whisper mode
    6 – barge mode

    e(ext): Enable *enforced* mode, so the spying channel can only
    monitor
    extensions whose name is in the : delimited list.

    E: Exit when the spied-on channel hangs up.

    g(grp):
    grp – Only spy on channels in which one or more of the groups
    listed in matches one or more groups from the ${SPYGROUP}
    variable set on the channel to be spied upon.
    NOTE: both
    and ${SPYGROUP} can contain either a single group
    or a colon-delimited list of groups, such as
    ‘sales:support:accountin
    g’.

    n([mailbox][@context]): Say the name of the person being spied on
    if that person has recorded his/her name. If a context is specified,
    then
    that voicemail context will be searched when retrieving the name,
    otherwise
    the ‘default’ context be used when searching for the name (i.e. if
    SIP/1000
    is the channel being spied on and no mailbox is specified, then
    ‘1000’
    will be used when searching for the name).

    o: Only listen to audio coming from this channel.

    q: Don’t play a beep when beginning to spy on a channel, or speak
    the selected channel name.

    r([basename]): Record the session to the monitor spool directory.
    An optional base for the filename may be specified. The default is

    chanspy’.

    s: Skip the playback of the channel type (i.e. SIP, IAX, etc) when
    speaking the selected channel name.

    S: Stop when no more channels are left to spy on.

    v([value]): Adjust the initial volume in the range from ‘-4’ to
    ‘4’. A negative value refers to a quieter setting.

    w: Enable ‘whisper’ mode, so the spying channel can talk to the
    spied-on channel.

    W: Enable ‘private whisper’ mode, so the spying channel can talk
    to the spied-on channel but cannot listen to that channel.

    x(digit):
    digit – Specify a DTMF digit that can be used to exit the
    application.

    X: Allow the user to exit ChanSpy to a valid single digit numeric
    extension in the current context or the context specified by the
    ${SP
    Y_EXIT_CONTEXT} channel variable. The name of the last channel that
    was
    spied on will be stored in the ${SPY_CHANNEL} variable.

  • Read the documentation. If I do Set(a=${CHANNELS()}) a will return a list
    of channels with a space between each entry like you originally said. I did
    my test using Set(a=${CHANNELS(1107)}) and it returned a=SIP/1107, therefore
    I logically assumed that ${CHANNELS(miq8)}) would return SIP/miq8. If you
    PROVE me wrong so be it, but I’m gonna SHUT UP now since you don’t give a
    rat’s behind about my wasting time trying to help you.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Wednesday, January 25, 2012 3:16 AM

    This could work, yes.

    But the context is not always the same.

    Also ${CHANNELS(miq8) will return nothing…

    Jonas.

    Did a little research on this using my Asterisk 10.0. This should work for
    you.

    exten => 1246,1,answer()

    exten => 1246,n,set(inuse=${CHANNELS(miq8)})

    exten => 1246,n,extenspy(${inuse}@default)

    exten => 1246,n,hangup()

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:52 AM

    Hello,

    there is very little information about the function CHANNELS().

    If I know the peer name (that I always know for sure), do you see a way of
    using the function CHANNELS() to get the right channel ??

    If CHANNELS() gives a “space-delimited” list of active channels, and I know
    miq8… how can I get SIP/miq8-00002419 ?

    Thanks !

    Extenspy(miq8@default) for miq8. I would either proceed under the
    assumption that I’m going to be listening to my extensions in the default
    context or set up an AGI or something to load my needed ext@context
    information.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:41 AM

    Hello,

    how to use ExtenSpy(extension@context) when conversations are named like
    this ? :

    SIP/378680644-00002 default
    SIP/rs4-00002445 sub-uitinternation
    SIP/3715320168-00002 default
    SIP/ibenla2-0000244 sub-uit789
    SIP/372083610-00002 default
    SIP/cedhou0-000024 sub-uit789
    SIP/travel3-00002 pbx-routing
    SIP/INTELin-00002 pbx-routing
    SIP/375382280-00002 default
    SIP/miq8-00002419 sub-uitGSM
    SIP/3749378004-0000 default
    SIP/instlpr0-00002 sub-uitinternation

    Can you tell me what is the extension ? How will I know the context ? The
    context is not always the same…

    You are either going to be able to listen to SIP/miq8 or you are going to
    have to know the sequence number like SIP/miq8-00001. Maybe you should just
    use ExtenSpy instead?

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:26 AM

    Of course I can control the name of my SIP-peer. Why do you tell me this ?!

    Please answer my question : how do I know the channel name so I can ChanSpy
    the correct channel ?

    It’s not random. The “Channel Name” is Tech/peer-sequence (sequence is in
    hex). You can control (to a degree) the peer portion in
    sip.conf/users.conf.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 9:07 AM

    Hello,

    thanks. miq8 is the name of the SIP peer account.

    So when I know the SIP peer name, and I strip of the numbers of the channel,
    then I can use ChanSpy. So this answers my original question.

    The only problem I see : it is Asterisk that gives the channel its name. How
    do I change this ??

    As far as I know, Asterisk randomly gives a channel name which consists of
    the technology (SIP), the peername (miq8) and some numbers…

    How to change the channel name ?

    I would try chanspy(sip/miq8,b) – the b flag denotes to only listen to a
    bridged call which (it seems to me) should pick up both sides.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 8:46 AM

    Hello,

    OK thanks. But, I want to listen to the conversation (not just 1 channel out
    of 2 channels). How then do I use ChanSpy ?

    Strip off the -xxxxx. Just listen to SIP/miq8 and SIP/375382280 in your
    example.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens
    Sent: Tuesday, January 24, 2012 7:47 AM

    Hello list,

    to use ChanSpy, one needs to know the name of the channel.

    But on an incoming call from the provider, or an outgoing call to the
    provider there are always numbers added. How can one then know the channel
    name ??

    core show channels verbose shows me for example :

    SIP/378680644-00002 default
    SIP/rs4-00002445 sub-uitinternation
    SIP/3715320168-00002 default
    SIP/ibenla2-0000244 sub-uit789
    SIP/372083610-00002 default
    SIP/cedhou0-000024 sub-uit789
    SIP/travel3-00002 pbx-routing
    SIP/INTELin-00002 pbx-routing
    SIP/375382280-00002 default
    SIP/miq8-00002419 sub-uitGSM
    SIP/3749378004-0000 default
    SIP/instlpr0-00002 sub-uitinternation
    SIP/372089170-00002 default
    SIP/v9q9uLT-0000 from-GFATRUNK
    46 active channels
    24 active calls

    If I want to listen to the conversation of SIP/miq8-00002419 and
    SIP/375382280-00002 (these 2 channels have been connected to 1
    conversation), how do I use ChanSpy ??

  • I confirm that ChanSpy does not need the complete channel name. The peer
    name is enough for ChanSpy to find the channel.

    I need further testing though to find out if both legs of the
    conversation can be listened to.

    Thanks.

    Jonas.