Asterisk cmd ChanSpy
Created by: JustRumours,Last modification on Wed 23 of Apr, 2008 [20:02 UTC] by thelimit
ChanSpy
Synopsis
Listen in on a call. Useful in a call center to monitor agents on the phone.Description
See bug 3836This adds the ability to spy on any bridged call, this includes VoIP only calls where ZapScan/ZapBarge couldn't this can.
Chanspy([<scanspec>][|<options>])
Valid 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.
Since 1.4:
- 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.
If <scanspec> is specified, only channel names *beginning* with that string will be scanned.
('all' or an empty string are also both valid <scanspec>)
While Spying:
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 <scanspec>
(e.g. run Chanspy(Agent) and dial 1234# while spying to jump to channel Agent/1234)
Update: Asterisk 1.4 include a 'whisper' feature as part of ChanSpy(): A third party may speak to only one of the two parties of a bridged call.
Attention
- Up to and including Asterisk 1.4.17 ChanSpy can cause a crash/segfault if used together with Monitor or Asterisk cmd MixMonitor at the same time. 1.4.18 is supposed to attack this issue by using "audiohooks" that replaces the current ChanSpy approach.
Example
exten => 556,1,ChanSpy(scan)Note:
ChanSpy will not work if you are Record()-ing the spied channel; unless you add transmit_silence_during_record=yes to the options section in /etc/asterisk/asterisk.confSee also
- ExtenSpy: Listen/whisper to a specific extension (introduced in Asterisk 1.4)
- Recording calls with Asterisk
- Asterisk cmd ZapBarge: Listen to a Zap channel call
- Asterisk cmd ZapScan
Version information
- As of october 19 2004, ChanSpy is not included in the standard Asterisk distribution or the development CVS tree.
- As of March 22 2005 this bug was reopened and can be viewed at above link.
- On March 24 2005 ChanSpy was added into CVS HEAD
Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ
Comments
333Creative solution for spying with console
Well ChanSpy seems broken, as are alot of other apps in Asterisk. But, some apps actually work better than expected and we can use this to solve the problem in a creative way!
The problem I have with chanspy is that it just doesn't do what the description says it should. And if I want to spy and talk to the channel from console, it just doesn't work.
For my solution, I used two standard programs for playing and recording under Linux/ALSA: aplay and arecord:
1. create two FIFO files in a directory of your choice:
user@computer:/temp# mkfifo play.raw
user@computer:/temp# mkfifo record.raw
user@computer:/temp# ls -l
prw-r--r-- 1 user user 0 2007-11-30 22:36 play.raw
prw-r--r-- 1 user user 0 2007-11-30 22:36 record.raw
2. create the following context in your extensions.conf file and redirect incoming calls to it:
test
exten => s,1,MixMonitor(/home/lucas/WoZ/play.raw,a)
exten => s,n,PLAYBACK(/home/lucas/WoZ/record)
exten => s,n,Hangup
3. run the following two commands in the afforementioned directory:
user@computer:/temp# aplay -f S16_LE -r 8000 -c 1 play.raw > /dev/null &
user@computer:/temp# arecord -f S16_LE -r 8000 -c 1 > record.raw
4. Call and now you can listen to and talk to the call in progress. Change PLAYBACK to BACKGROUND to run sth else before hangup.
333SPYGROUP g option
exten => _9X.,1,Set(SPYGROUP=10001)
333SPYGROUP g option
exten => 1234,1,ChanSpy(|g(10001))
exten => 1234,2,Hangup
This would then allow you to spy on any call that set $SPYGROUP to "10001" like this:
exten => _9X.,1,SetVar(SPYGROUP=10001)
any calls with SPYGROUP set to another value would not be selected by ChanSpy even if the rest of the parameters matched.
333ChanSpy removed from Mantis?