Extension Monitoring Recipe

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.

[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.

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.

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 )

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.

.
.
- 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. )

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.

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?

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 ?