Extension Monitoring Recipe

Discussion in 'General' started by wfulton, Aug 4, 2009.

  1. wfulton

    Joined:
    Jul 2, 2009
    Messages:
    15
    Likes Received:
    0
    Hi all,

    I chose to post this because it took me a day or two to figure out how to do this. This script is modified and patched together from some pieces of asterisk commands I found in a couple of different asterisk forums.

    This custom feature code will allow an authenticated user to use chanspy in a directed fashion in order to listen to a specific extension for monitoring purposes. Please replace the #'s with whichever feature codes you want to use, this goes for the Authenticate box as well.

    [from-internal-custom]
    exten => ###,1,Authenticate(####)
    exten => ###,2,Read(SPYNUM,extension)
    exten => ###,3,ChanSpy(SIP/${SPYNUM},q)

    Bill
     
  2. morganmasner

    Joined:
    Aug 22, 2009
    Messages:
    2
    Likes Received:
    0
    Thanks for this! If I want anyone to monitor a specific extension with out the authentication process, would I just omit the authentication line? Thanks
     
  3. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Pretty well, If you want to monitor Ques or ZAP or IAX2 etc. from the horses mouth:

    *CLI> core show application chanspy
    *CLI>
    -= Info about application 'ChanSpy' =-

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

    [Description]
    ChanSpy([chanprefix][|options]): 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.
    - Dialing * will stop spying and look for another channel to spy on.
    - Dialing a series of digits followed by # builds a channel name to append
    to 'chanprefix'. For example, executing ChanSpy(Agent) and then dialing
    the digits '1234#' while spying will begin spying on the channel
    'Agent/1234'.
    Options:
    b - Only spy on channels involved in a bridged call.
    g(grp) - Match only channels where their ${SPYGROUP} variable is set to
    contain 'grp' in an optional : delimited list.
    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'.
    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.
     
  4. wfulton

    Joined:
    Jul 2, 2009
    Messages:
    15
    Likes Received:
    0
    yes, exactly. Just remove the first line. I would recommend not doing this. If you have multiple users on the system the only security you have from a feature like this is obscurity if you remove the authentication line.

    Dicko, the implementation of Chanspy in almost any Asterisk Distro is badly broken and tends to spy randomly in my experience. This recipe allows it to be directed properly. Thanks for the additional information.
     
  5. morganmasner

    Joined:
    Aug 22, 2009
    Messages:
    2
    Likes Received:
    0
    Awesome, thanks so much to both of you for the info! Really helpful.
     
  6. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    I appreciate your comment:

    In my experience I wouldn't say it is broken, if you call it with a technology and that technology is enumerated (like zap, or Agents or sip extensions, it works as advertised, just as documented in my previous post (particularly . . builds a channel name to append
    to 'chanprefix'. . .). If called to an un-enumerated chanprefix like an inbound sip trunk (or no chanprefix at all), of course it is random, The only "broken" thing I am aware of is, you can never get to ZAP/1 (so I am careful to remember to be "off by 2", see I'm c based :) )
     
  7. wfulton

    Joined:
    Jul 2, 2009
    Messages:
    15
    Likes Received:
    0
    In my application we used it from one sip extension and tried to attach to another to listen, but it failed in all cases and would only result in random channel surfing. So, we rewrote the recipe like this to cause it to work as we needed it. I have no doubt it works in some way, but not for us.

    Thanks again for the additional info!
     
  8. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    To be pedantic, but in no way to undermine your efforts:

    .
    .
    - Dialing a series of digits followed by # builds a channel name to append
    to 'chanprefix'. For example, executing ChanSpy(Agent) and then dialing
    the digits '1234#' while spying will begin spying on the channel
    'Agent/1234'.
    .
    .

    If you want to get to a technology/channel it must of course be called with that technology, as you indeed did, My post was just largely in defense of chanspy, it works (largely) as advertised, and is not as you claim broken, as your own context proves. It's just a matter of "reading the manual". :)

    if you dialed sip/1234# in 555 it would work, (damn only got digits on my dial pad, never mind. :) )


    Perhaps I might modify your original post to:


    exten => ###,1,Authenticate(####,a,4); if you need it (a to audit 4 for efficiency here)
    exten => ###,n,ChanSpy(SIP) ; n = 1 if you didn't need it (or ZAP, AGENT etc.)
    exten => ###,n,Hangup() ; because it's good pracice

    which gives a manager a lot of flexibility, after the beep, (no q parameter) # for volume , * for another channel, 1234# for a particular channel, and (s)he can channel surf (enumerated, active SIP channels) accurately all day long.

    JM2CWAE
     
  9. VoIPDoug

    Joined:
    Mar 1, 2009
    Messages:
    28
    Likes Received:
    0
    Clarify for me if you will what the context ${SPYNUM} is in this macro? I'm understanding most of this except what this context addition is telling the system to do. Where's it come from and what's it for?
     
  10. wfulton

    Joined:
    Jul 2, 2009
    Messages:
    15
    Likes Received:
    0
    You will be prompted for the channel number you want to spy on. This is what ${SPYNUM} represents. It is entered manually when using the chanspy tool.

    Thanks!
     
  11. jammerz

    Joined:
    Sep 7, 2009
    Messages:
    75
    Likes Received:
    0
    Thanks Dicko,

    I have been looking for info specifics as you mention but also hoping that a feature code was already created for whisper mode as the Digium guys include with their products. Am I to understand that we must customize our own whisper mode (W) option verses having a feature code already available to us, ie. *somenumber ?

    jf
     
  12. ReserDj

    Joined:
    Sep 23, 2009
    Messages:
    112
    Likes Received:
    0
    Hey guy! thanks a lot for this solution i've been looking for something like this, i tried what you have posted and this worked great, at least for a while this is a good solution for spy calls.
     

Share This Page