Friday, October 7, 2011

Shell Script to monitor the services and ports running in the linux system in the different Format

The Script read the service running the Linux system in the different  format

The Script read the port number from the sample.txt  file and service name

 sample .txt#INSTANCE_NAME:PORT:USER:EXTERNAL_PORT
http 80 root 81
https 443 root
ssh 22 rrot mail 25 rrotftp 21 root  
#!/bin/bash

cat /root/sample.txt|grep -v "^#"| while read line
do
#echo $line

NETSTAT=/bin/netstat
# for old file
INSTANCE_NAME=`echo $line | awk '{print $1}'`
PORT_NO=`echo $line | awk '{print $2}'`
USER=`echo $line | awk '{print $3}'`
# for new file
#INSTANCE_NAME=`echo $line | awk -F':' '{ print $1 }'`
#PORT_NO=`echo $line | awk -F':' '{ print $2 }'`
#USER=`echo $line | awk -F':' '{ print $3 }'`
echo $INSTANCE_NAME
echo  $PORT_NO
echo $USER
RPORTS=$($NETSTAT -utan|awk '{print $4}'
|sed -s "s/::ffff:[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]/::/g"
|sed -s "s/0.0.0.0/::/g"|sed -s "s/127.0.0.1/::/g"|sed -s "s/[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]/::/g"|
cut -f4 -d":"|grep -v 127.0.0.1)

  status="NO"
  for r in $RPORTS
  do
   if [ "$r" == "$PORT_NO" ]
   then
    status="YES"
    break
   fi
  done
  echo -n " $INSTANCE_NAME is running $status with user as $USER"
  echo ""
done
 
 
it monitor the services 
0.0.0.0:80
 :::8080
::ffff:127.0.0.1:8005 

Thursday, July 7, 2011

Cricinfo International Scores

Cricinfo International Scores: "Get the latest scores of all the international cricket matches from Cricinfo. Add the Cricinfo International Scores widget now!"

Monday, January 31, 2011

Apache, Tomcat cluster, load balancing using mod_jk

Apache

The Apache HTTP Server Project is a collaborative software development effort aimed at creating a robust, commercial-grade, feature ful, and freely-available source code implementation of an HTTP (Web) server. The project is jointly managed by a group of volunteers located around the world, using the Internet and the Web to communicate, plan, and develop the server and its related documentation. This project is part of the Apache Software Foundation. In addition, hundreds of users have contributed ideas, code, and documentation to the project. This file is intended to briefly describe the history of the Apache HTTP Server and recognize the many contributors. 

Tomcat

Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies. The Java Servlet and Java Server Pages specifications are developed under the Java Community Process.
Apache Tomcat is developed in an open and participatory environment and released under the Apache License version 2. Apache Tomcat is intended to be a collaboration of the best-of-breed developers from around the world. We invite you to participate in this open development project.

 Download the required software 

  • Apache 2.x Binaries 
  • Tomcat 6.x Binaries
  • The JK module
Installing of Apache and Tomcat   please refer previous posting of installing of Apache and Tomcat

load the mod_jk.so module 
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
below DOcument Root
JkMount /*.jsp loadbalancer
JkMount /servlet/* loadbalancer
And create worker.properties file in /etc/httpd/conf/ directory
#
# workers.properties 
#

# In Unix, we use forward slashes:
ps=/

# list the workers by name

worker.list=tomcat1, tomcat2, loadbalancer

# ------------------------
# First tomcat server
# ------------------------
worker.tomcat1.port=8019
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13

# Specify the size of the open connection cache.
#worker.tomcat1.cachesize

#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
#  ----> lbfactor must be > 0
#  ----> Low lbfactor means less work done by the worker.
worker.tomcat1.lbfactor=100


# ------------------------
# Second tomcat server
# ------------------------
worker.tomcat2.port=8029
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13

# Specify the size of the open connection cache.
#worker.tomcat2.cachesize

#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
#  ----> lbfactor must be > 0
#  ----> Low lbfactor means less work done by the worker.
worker.tomcat2.lbfactor=100


# ------------------------
# Load Balancer worker
# ------------------------

#
# The loadbalancer (type lb) worker performs weighted round-robin
# load balancing with sticky sessions.
# Note:
#  ----> If a worker dies, the load balancer will check its state
#        once in a while. Until then all work is redirected to peer
#        worker.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1, tomcat2

#
# END workers.properties
#
 
 
and goto the tomcat server1 and edit the file /opt/tomcat1/conf/server.xml
 
edit  line 
 

                                                   to

 

             to
     
 
and goto the tomcat server2 and edit the file /opt/tomcat2/conf/server.xml

to

 


  
             to
     
 
 
In  apache server
 
NameVirtualHost *


ServerName localhost1
JkMount /*.jsp tomcat1
JkMount /servlet/* tomcat1


ServerName localhost2
JkMount /*.jsp tomcat2
JkMount /servlet/* tomcat2
 
 
And save the files and restart the both tomcat1 and tomcat2 server and apache start
and in browser
http://localhost
 
apache index.html will dispaly
and http://localhost/index.jsp
 
request go to server1 and continue if will server load heavy
 it will redirect to server2 or in case of fail over 

Redirecting Request from apache to tomcat Server using Mod jk

Apache

The Apache HTTP Server Project is a collaborative software development effort aimed at creating a robust, commercial-grade, feature ful, and freely-available source code implementation of an HTTP (Web) server. The project is jointly managed by a group of volunteers located around the world, using the Internet and the Web to communicate, plan, and develop the server and its related documentation. This project is part of the Apache Software Foundation. In addition, hundreds of users have contributed ideas, code, and documentation to the project. This file is intended to briefly describe the history of the Apache HTTP Server and recognize the many contributors. 

Tomcat

Apache Tomcat is an open source software implementation of the Java Servlet and Java Server Pages technologies. The Java Servlet and Java Server Pages specifications are developed under the Java Community Process.
Apache Tomcat is developed in an open and participatory environment and released under the Apache License version 2. Apache Tomcat is intended to be a collaboration of the best-of-breed developers from around the world. We invite you to participate in this open development project.

using mod_proxy.so and mod_proxy_ajp.so


load module in Apache
edit the file /etc/httpd/conf/httpd.conf
uncomment or add

Download Mod_jk binary from
wget http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux

workers.properties File

  • Create the workers.properties in your apache configuration directory. Example:
    touch /etc/apache2/workers.properties
    
  • Using your favorite editor (I like to use vi), edit the file and add the following information (tailor it to suit your system):
       workers.tomcat_home=/opt/tomcat6
       workers.java_home=/opt/java
       ps=/
       worker.list=worker1
    
       worker.worker1.port=8009
       worker.worker1.host=127.0.0.1
       worker.worker1.type=ajp13
       worker.worker1.lbfactor=1
    

Virtual Host File


This is probably the most vital step that is missing in a lot of how-to's. The JkMount directive must be added to the virtual host file containing port 80. The virtual host definition may also be present in your apache2.conf or httpd.conf file. If not, create a new file called something like default.conf, add the contents below, and put default.conf somewhere in which it can be properly loaded by apache2.conf (or httpd.conf).
    
       ServerName your.hostname.com
    
       # Send servlet for context /jsp-examples to worker named worker1
       JkMount /jsp-examples worker1
    
       # Send JSPs for context /jsp-examples/* to worker named worker1
       JkMount /jsp-examples/* worker1
    
     
     

save the file  and restart the httpd server

and goto tomcat install directory

conf directory and edit server.xml

and restart the tomcat server

Test It


To test your setup, type http://localhost/jsp-examples. It should also work with http://localhost:8080/jsp-examples.  

it will redirect to tomcat jsp-examples  home page

Creating Secure Site in Tomact and Apache

Apache Tomcat

Apache Tomcat is an open source software implementation of the Java Servlet and Java Server Pages technologies. The Java Servlet and Java Server Pages specifications are developed under the Java Community Process.
Apache Tomcat is developed in an open and participatory environment and released under the Apache License version 2. Apache Tomcat is intended to be a collaboration of the best-of-breed developers from around the world. We invite you to participate in this open development project. 

Installation of Apache Tomcat

Downloads the tar file for

http://apache.cs.utah.edu/tomcat/tomcat-6/v6.0.30/bin/apache-tomcat-6.0.30.tar.gz

tar -zxvf  Apache-tomcat-6.0.30.tar.gz
cp -r   tomcat /opt/tomcat

and write a start up scripts
create a file tomcat in /etc/init.d  give chmod 777 permissions to tomcat file
copy the 

#!/bin/bash
# chkconfig: - 10 20
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
PATH=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/bin:$PATH:$HOME/bin:./
export PATH
 export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre
export CLASSPATH=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/lib/tools.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/lib/dt.jar:./
export CATALINA_HOME=/opt/tomcat/
export CATALINA_TMPDIR=/opt/tomcat/temp
unset USERNAME

start()
{
cd /opt/tomcat6/bin/
sh startup.sh
}
stop()
{
cd /opt/tomcat/bin/
sh shutdown.sh
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "start | stop | restart"
esac

save the file

and  start tomcat  /etc/init.d/tomcat start
and stop tomcat /etc/init.d/tomcat stop

http://localhost:8080

to create Secure site https

goto 
cd /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/bin

keytool -genkey -alias name-keypass admin123  -keystore domainnamecom.bin -storepass admin123
Note:keypass  and storepass  must be same password
it generate a file with name domainnamecom.bin in same directory
copy the file domainnamecom.bin to /opt/tomcat/webapps

and Goto cd /opt/tomcat/conf

and edit server.xml

and uncommmnet

   
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" keystoreFile="../webapps/domainnamecom.bin" keystorePass="admin123"  />

and save the server.xml
and restart the tomcat server

https://localhost:8443


Apache Server

The Apache HTTP Server Project is a collaborative software development effort aimed at creating a robust, commercial-grade, feature ful, and freely-available source code implementation of an HTTP (Web) server. The project is jointly managed by a group of volunteers located around the world, using the Internet and the Web to communicate, plan, and develop the server and its related documentation. This project is part of the Apache Software Foundation. In addition, hundreds of users have contributed ideas, code, and documentation to the project. This file is intended to briefly describe the history of the Apache HTTP Server and recognize the many contributors. 

Compiling and Installing
Downloads source tar http://httpd.apache.org/download.cgi
tar -zxvf  httpd-NN.tar
cd httpd
./configure --prefix=PREFIX
make
make install

configuration file is in 
/etc/httpd/conf/httpd.conf


to start
/etc/init.d/httpd start
to stop
 /etc/init.d/httpd stop 

and in browser 

http://localhost


To Create secure site 
install mod_ssl and open_ssl

then generate a key file
 openssl genrsa -out /etc/httpd/ssl/domain.com.key 1024

and using the key file generate certiifcate for 999 days

openssl req -new -key /etc/httpd/ssl/domain.com.key -x509 -out /etc/httpd/ssl/domainname.crt -days 999

and edit the /etc/httpd/conf/httpd.conf

 copy the lines

DocumentRoot "/var/www/html/ssl_doc_root/"
ServerAdmin you@mycorp.com
ServerName servername
SSLEngine On
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /etc/httpd/ssl/domain.crt
SSLCertificateKeyFile /etc/httpd/ssl/domain.com.key
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0


save the file
restart the httpd server


and in browser

https://localhost
 

Thursday, January 20, 2011

FreeSwitch Installation Steps in centos and Debain

     Freeswitch
  
FreeSWITCH is a scalable open source cross-platform telephony platform designed to route and interconnect popular communication protocols using audio, video, text or any other form of media.  It was created in 2006 to fill the void left by proprietary commercial solutions. FreeSWITCH also provides a stable telephony platform on which many telephony applications can be developed using a wide range of free tools.

FreeSWITCH was originally designed and implemented by Anthony Minessale with the help of Brian West and Michael Jerris. All 3 are former developers of the popular Asterisk open source PBX.  The project was initiated to focus on several design goals including modularity, cross-platform support, scalability and stability. Today, many more developers and users contribute to the project on a daily basis.

We support various communication technologies such as Skype, SIP, H.323 and GoogleTalk making it easy to interface with other open source PBX systems such as sipXecs, Call Weaver, Bayonne, YATE or Asterisk.

FreeSWITCH supports many advanced SIP features such as presence/BLF/SLA as well as TCP TLS and sRTP. It also can be used as a transparent proxy with and without media in the path to act as a SBC (session border controller) and proxy T.38 and other end to end protocols.

FreeSWITCH supports both wide and narrow band codecs making it an ideal solution to bridge legacy devices to the future. The voice channels and the conference bridge module all can operate at 8, 12, 16, 24, 32 or 48 kilohertz and can bridge channels of different rates. The G.729 codec is also available under a commercial license.

FreeSWITCH builds natively and runs standalone on several operating systems including Windows, Max OS X, Linux, BSD and Solaris on both 32 and 64 bit platforms.

FreeSWITCH supports FAX, both over audio and T.38, and can gateway between the two.


Centos Or Redhat 
Installation Steps

yum install subversion autoconf automake libtool gcc-c++ ncurses-devel make expat-devel zlib zlib-devel
Dependencies For Additional Modules in freeswitch
yum install nano unixODBC-devel openssl-devel gnutls-devel libogg-devel libvorbis-devel curl-devel
Installation git in centos
yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel
 
wget http://kernel.org/pub/software/scm/git/git-1.6.1.tar.gz
untar the git source code
 
tar xvfz git-1.6.1.tar.gz 
cd git-1.6.1.tar.gz
make prefix=/usr/local all
make prefix=/usr/local install

Downloads the source of Freeswitch from git and install

cd /usr/src/
git clone git://git.freeswitch.org/freeswitch.git
cd /usr/src/freeswitch
./bootstrap.sh
./configure
make install
make cd-sounds-install
make cd-moh-install
it install  default modules of Freeswitch if you needed additional modules
go to /usr/src/freeswitch 
edit the modules.conf
uncomment the modules need
and 
make install
 
 
In Debian
apt-get install autoconf automake g++ git-core libjpeg62-dev libncurses5-dev libtool make
cd /usr/src/
git clone git://git.freeswitch.org/freeswitch.git
cd /usr/src/freeswitch
./bootstrap.sh
./configure
make install
make cd-sounds-install
make cd-moh-install
it install  default modules of Freeswitch if you needed additional modules
go to /usr/src/freeswitch 
edit the modules.conf
uncomment the modules need
and 
make install
Start and stop commands
start
/usr/local/freeswitch/bin/freeswitch -nc  ;non console
stop 
/usr/local/freeswitch/bin/freeswitch -stop 
start up scripts
create a file in /etc/init.d/freeswitch
#!/bin/sh
#
# freeswitch.sh - startup script for freeswitch on FreeBSD
#
# This goes in /usr/local/etc/rc.d and gets run at boot-time.

case "$1" in

    start)
    if [ -x /usr/local/freeswitch/bin/freeswitch ] ; then
        echo -n " freeswitch"
        /usr/local/freeswitch/bin/freeswitch -nc &
    fi
    ;;

    stop)
    if [ -x /usr/local/freeswitch/bin/freeswitch ] ; then
        echo -n " freeswitch"
        /usr/local/freeswitch/bin/freeswitch -stop &
    fi
    ;;

    *)
    echo "usage: $0 { start | stop }" >&2
    exit 1
    ;;

esac 
and give permissions of 
chmod 755
chkconfig --add freeswitch
chkconfig --level 5 freeswitch on
chkconfig --list freeswitch
 


Read the File With Comma separte and copy the files to directory using Perl script

To read the File and copy the files to the directorywith comma separate need the the Package

  FileHandle.


#!/usr/bin/perl

use FileHandle;

if (@ARGV != 2) {
    print  " the argument is invalided \n"   ;
  exit 1;
}

$file_name = shift;
$output_path = shift;

print "$file_name ,$output_path \n";
$dir1 = "/opt/test";

open (FILE, "$file_name") or die "Cannot open $file_name $!\n";

@fields;
while () {
      chomp;
    @fields = split(/\,/);
   
      foreach my $item (@fields) {
      #print "$item  \n";
   }

    if ($#fields < 1) {
        print " Error in file format \n";
        next;
    }
   
   $file_id = $fields[4];
    print  " $file_id \n";        

    `cp -r "$dir1/$file_id" "$output_path/$file_id" `;

 }
close (FILE);



give permissons to file of script and

perl test.pl new.txt  /opt/test/copy

new.txt file format
1,wer,2,root,welcome.txt
2,wee,3,root,welcome1.log
3,333,4,root,sysd.log

Reading the Csv File and inser into Database using the Perl Script

To read the CSV File or Xls file the following packages is needed

Spreadsheet::ParseExcel::Simple
Spreadsheet::ParseExcel
DBI

the perl script


#!/usr/bin/perl

use DBI;
use Spreadsheet::ParseExcel::Simple;
use Spreadsheet::ParseExcel;

my $workbook = Spreadsheet::ParseExcel::Workbook->Parse('Agent Details.xls');

#==================================================
#==================================================
foreach $sheet (@{$workbook->{Worksheet}}) {

       foreach $col ($sheet->{MinCol} .. $sheet->{MaxCol}) {
              
               if ($sheet->{Cells}[0][$col]->{Val} eq "COL1") {
                       $col1= $col;
               }
               if ($sheet->{Cells}[0][$col]->{Val} eq "COL2") {
                       $col2= $col;
               }
               if ($sheet->{Cells}[0][$col]->{Val} eq "COL3") {
                       $col3= $col;
               }
               if ($sheet->{Cells}[0][$col]->{Val} eq "COL4") {
                       $col4= $col;
               }
       }
#==================================================
#==================================================
       foreach $row ($sheet->{MinRow}+1 .. $sheet->{MaxRow}) {

                  $col_1 = $sheet->{Cells}[$row][$col1]->{Val};
                  $col_2 = $sheet->{Cells}[$row][$col2]->{Val};
                  $col_3 = $sheet->{Cells}[$row][$col3]->{Val};
                  $col_4 = $sheet->{Cells}[$row][$col4]->{Val};

#==================================================
#==================================================
                if( $col_1!= ' ' && $col_2!= ' ' && col_3 !=' ' && col_4 != ' ')
                {
                    $dbh = DBI->connect("DBI:mysql:databasename:localhost:3306", "username", "password")
                     or die "Couldn't connect to database: " . DBI->errstr;
                    $stmt = "INSERT INTO databasename.tablename (col1,col2,col3,col4) values ( '$col_1' ,'$col_2','$col_3','$col_4');";
                    $affected_rows = $dbh->do($stmt);
                }
       }
}
#==================================================



Friday, December 10, 2010

Asterisk Integration With Openldap

LDAP integration for Asterisk

The "light weight directory" offers a means for central user administration for your network, including VoIP data.


To integration openldap with Asterisk


First Install and Configure the Openldap Server
After Installation Asterisk
In Extconfig.config do Following Changes


;     sipusers => ldap,"dc=myDomain,dc=myDomainExt",sip
;     sippeers => ldap,"dc=myDomain,dc=myDomainExt",sip
;     extensions => ldap,"dc=myDomain,dc=myDomainExt",extensions
;     sip.conf => ldap,"dc=myDomain,dc=myDomainExt",config
;      voicemail => ldap,"dc=myDomain,dc=myDomainExt",voicemail


And In res_ldap.conf

 [_general]
; Specify one of either host and port OR url.  URL is preferred, as you can
; use more options.
;host=192.168.1.1                    ; LDAP host
;port=389                                 ;Ldap port
;url=ldap://ldap3.mydomain.com:3890
;protocol=3                          ; Version of the LDAP protocol to use; default is 3.
;basedn=MyRootDN                     ; Base DN
;user=MyDN                              ; Bind DN
;pass=MyPassword                     ; Bind password


And
[config]
;
; additionalFilter - This specifies an additional set of criteria to be used
; when querying the LDAP server.
additionalFilter=(objectClass=AstConfig)
;
filename = AstConfigFilename
category = AstConfigCategory
variable_name = AstConfigVariableName
variable_value = AstConfigVariableValue
cat_metric = AstConfigCategoryMetric
commented = AstConfigCommented


[extensions]
context  =  AstExtensionContext
exten  =  AstExtensionExten
priority = AstExtensionPriority
app = AstExtensionApplication
appdata = AstExtensionApplicationData
additionalFilter=(objectClass=AstExtension)

[sip]
name = cn
amaflags = AstAccountAMAFlags
callgroup = AstAccountCallGroup
callerid = AstAccountCallerID
directmedia = AstAccountDirectMedia
context = AstAccountContext
dtmfmode = AstAccountDTMFMode
fromuser = AstAccountFromUser
fromdomain = AstAccountFromDomain
fullcontact = AstAccountFullContact
fullcontact = gecos
host = AstAccountHost
insecure = AstAccountInsecure
mailbox = AstAccountMailbox
md5secret = realmedPassword    ; Must be an MD5 hash. Field value can start with ,{md5} but it is not required.
nat = AstAccountNAT
deny = AstAccountDeny
permit = AstAccountPermit
pickupgroup = AstAccountPickupGroup
port = AstAccountPort
qualify = AstAccountQualify
restrictcid = AstAccountRestrictCID
rtptimeout = AstAccountRTPTimeout
rtpholdtimeout = AstAccountRTPHoldTimeout
type = AstAccountType
disallow = AstAccountDisallowedCodec
allow = AstAccountAllowedCodec
MusicOnHold = AstAccountMusicOnHold
regseconds = AstAccountExpirationTimestamp
regcontext = AstAccountRegistrationContext
regexten = AstAccountRegistrationExten
CanCallForward = AstAccountCanCallForward
ipaddr = AstAccountIPAddress
defaultuser = AstAccountDefaultUser
regserver = AstAccountRegistrationServer
lastms = AstAccountLastQualifyMilliseconds
additionalFilter=(objectClass=AsteriskSIPUser)


[voicemail]
context = AstAccountContext
mailbox = AstAccountMailbox
password=AstAccountPassword
email=AstAccountEmail
pager=AstAccountPager
tz=AstAccountTz
attach=AstAccountAttach
saycid=AstAccountSaycid
dialout=AstAccountDialout
callback=AstAccountCallback
review=AstAccountReview
operator=AstAccountOperator
envelope=AstAccountEnvelope
sayduration=AstAccountSayduration
saydurationm=AstAccountSaydurationm

sendvoicemail=AstAccountSendvoicemail
delete=AstAccountDelete
forcename=AstAccountForcename
forcegreetings=AstAccountForcegreetings
hidefordir=AstAccountHidefordir
stamp=AstAccountStamp


In extensions.conf
  exten => 1234,1,LDAPget(CIDNAME=cidname/${CALLERIDNUM},${CALLERIDNUM},${CALLERIDNUM})
exten => 1234,2,SetCIDName(${CIDNAME}) 

exten => 1234,3,Dial(SIP/${EXTEN},15

Monday, November 15, 2010

Asterisk Queues Log In to Database

In order to properly manage ACD queues, it is important to be able to keep track of details of call setups and teardowns in much greater detail  than traditional call detail records provide. In order to support this,
extensive and detailed tracing of every queued call is stored in the  queue log, located (by default) in /var/log/asterisk/queue_log. 

For asterisk 1.6.1Above

Create a table queue_log in MYSQL DB
CREATE TABLE `asterisk.queue_log` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `time` int(10) unsigned default NULL,
  `callid` varchar(32) NOT NULL default '',
  `queuename` varchar(32) NOT NULL default '',
  `agent` varchar(32) NOT NULL default '',
  `event` varchar(32) NOT NULL default '',
  `data` varchar(255) NOT NULL default '',
  `data1` varchar(255) NOT NULL default '',
  `data2` varchar(255) NOT NULL default '', 
  `data3` varchar(255) NOT NULL default '',
  `data4` varchar(255) NOT NULL default '',
  PRIMARY KEY (`id`)
);

mysql> select * from queue_log;
+----+------------+--------------+------------------+-------+------------+-------+
| id | time       | callid       | queuename        | agent | event      | data  |
+----+------------+--------------+------------------+-------+------------+-------+
| 1  | 1198356717 | 1198356717.0 | voipsolutions.ru | NONE  | ENTERQUEUE | |serg |
| 2  | 1198356719 | 1198356717.0 | voipsolutions.ru | NONE  | ABANDON    | 1|1|2 |
+----+------------+--------------+------------------+-------+------------+-------+ 
Data field values is separated by Pipe(|) symbols 

CREATE TABLE IF NOT EXISTS `agent_status` (
 `agentId` varchar(40) NOT NULL default '',
 `agentName` varchar(40) default NULL,
 `agentStatus` varchar(30) default NULL,
 `timestamp` timestamp NULL default NULL,
 `callid` double(18,6) unsigned default '0.000000',
 `queue` varchar(20) default NULL,
 PRIMARY KEY  (`agentId`),
 KEY `agentName` (`agentName`),
 KEY `agentStatus` (`agentStatus`,`timestamp`,`callid`),
 KEY `queue` (`queue`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


CREATE TABLE IF NOT EXISTS `call_status` (
 `callId` double(18,6) NOT NULL,
 `callerId` varchar(13) NOT NULL,
 `status` varchar(30) NOT NULL,
 `timestamp` timestamp NULL default NULL,
 `queue` varchar(25) NOT NULL,
 `position` varchar(11) NOT NULL,
 `originalPosition` varchar(11) NOT NULL,
 `holdtime` varchar(11) NOT NULL,
 `keyPressed` varchar(11) NOT NULL,
 `callduration` int(11) NOT NULL,
 PRIMARY KEY  (`callId`),
 KEY `callerId` (`callerId`),
 KEY `status` (`status`),
 KEY `timestamp` (`timestamp`),
 KEY `queue` (`queue`),
 KEY `position` (`position`,`originalPosition`,`holdtime`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
 
And then Created a trigger on the DB asterisk
 
DROP TRIGGER IF EXISTS `asterisk`.`queueEvents`;
DELIMITER //
CREATE TRIGGER `asterisk`.`queueEvents` BEFORE INSERT ON `asterisk`.`queue_log`
FOR EACH ROW BEGIN
 IF NEW.event = 'ADDMEMBER' THEN
   INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES
 (NEW.agent,'READY',NEW.time,NULL) ON DUPLICATE KEY UPDATE agentStatus = "READY", timestamp = NEW.time, callid = NULL; 
 ELSEIF NEW.event = 'REMOVEMEMBER' THEN
   INSERT INTO `agent_status` (agentId,agentStatus,timestamp,callid) VALUES 
(NEW.agent,'LOGGEDOUT',NEW.time,NULL) ON DUPLICATE KEY UPDATE agentStatus = "LOGGEDOUT", timestamp = NEW.time, callid = NULL;
 ELSEIF NEW.event = 'PAUSE' THEN
   INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES
 (NEW.agent,'PAUSE',NEW.time,NULL) ON DUPLICATE KEY UPDATE agentStatus = "PAUSE", timestamp = NEW.time, callid = NULL; 
 ELSEIF NEW.event = 'UNPAUSE' THEN
   INSERT INTO `agent_status` (agentId,agentStatus,timestamp,callid) VALUES
 (NEW.agent,'READY',NEW.time,NULL) ON DUPLICATE KEY UPDATE agentStatus = "READY", timestamp = NEW.time, callid = NULL;
 ELSEIF NEW.event = 'ENTERQUEUE' THEN
   REPLACE INTO `call_status` VALUES (NEW.callid,replace(replace(substring(substring_index(NEW.data, '|', 2), length(substring_index(New.data, '|', 2 - 1)) + 1), '|', ''), '|', ''),'inQue',NEW.time,NEW.queuename,'','','','',0);
 ELSEIF NEW.event = 'CONNECT' THEN
   UPDATE `call_status` SET callid = NEW.callid,status = NEW.event,timestamp = NEW.time,queue = NEW.queuename,holdtime = 
replace(substring(substring_index(NEW.data, '|', 1), length(substring_index(NEW.data, '|', 1 - 1)) + 1), '|', '') where callid = NEW.callid;
INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES(NEW.agent,NEW.event,NEW.time,NEW.callid)ON DUPLICATE KEY UPDATEagentStatus = NEW.event,timestamp = NEW.time,callid = NEW.callid;
 ELSEIF NEW.event in ('COMPLETECALLER','COMPLETEAGENT') THEN
   UPDATE `call_status` SET callid = NEW.callid,status = NEW.event,timestamp = NEW.time,queue = NEW.queuename,originalPosition =
 replace(substring(substring_index(NEW.data, '|', 3), length(substring_index(NEW.data, '|', 3 - 1)) + 1), '|', ''),holdtime = 
replace(substring(substring_index(NEW.data, '|', 1), length(substring_index(NEW.data, '|', 1 - 1)) + 1), '|', ''),callduration = replace(substring(substring_index(NEW.data, '|', 2), length(substring_index(NEW.data, '|', 2 - 1)) + 1), '|', '') 
where callid = NEW.callid;
INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,NEW.event,NEW.time,NULL) ON DUPLICATE KEY 
UPDATE agentStatus = "READY", timestamp = NEW.time, callid = NULL;
 ELSEIF NEW.event in ('TRANSFER') THEN
   UPDATE `call_status` SET callid = NEW.callid,status = NEW.event,timestamp = NEW.time,queue = NEW.queuename,holdtime = replace(substring(substring_index(NEW.data, '|', 1), length(substring_index(NEW.data, '|', 1 - 1)) + 1), '|', ''),callduration =
 replace(substring(substring_index(NEW.data, '|', 3), length(substring_index(NEW.data, '|', 3 - 1)) + 1), '|', '') where callid = NEW.callid;
INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES(NEW.agent,'READY',NEW.time,NULL)ON DUPLICATE KEY 
UPDATE agentStatus = "READY",timestamp = NEW.time,callid = NULL;
 ELSEIF NEW.event in ('ABANDON','EXITEMPTY') THEN 
   UPDATE `call_status` SET callid = NEW.callid,status = NEW.event,timestamp = NEW.time,queue = NEW.queuename,position = replace(substring(substring_index(NEW.data, '|', 1), length(substring_index(NEW.data, '|', 1 - 1)) + 1), '|', ''),originalPosition = 
replace(substring(substring_index(NEW.data, '|', 2), length(substring_index(NEW.data, '|', 2 - 1)) + 1), '|', ''),holdtime = replace(substring(substring_index(NEW.data, '|', 3), length(substring_index(NEW.data, '|', 3 - 1)) + 1), '|', '') 
where callid = NEW.callid;
 ELSEIF NEW.event = 'EXITWITHKEY'THEN 
   UPDATE `call_status` SET callid = NEW.callid,status = NEW.event,timestamp = NEW.time,queue = NEW.queuename,position = replace(substring(substring_index(NEW.data, '|', 2), length(substring_index(NEW.data, '|', 2 - 1)) + 1), '|', ''),keyPressed =
 replace(substring(substring_index(NEW.data, '|', 1), length(substring_index(NEW.data, '|', 1 - 1)) + 1), '|', '') where callid = NEW.callid;
 ELSEIF NEW.event = 'EXITWITHTIMEOUT' THEN 
   UPDATE `call_status` SET callid = NEW.callid,status = NEW.event,timestamp = NEW.time,queue = NEW.queuename,position = 
replace(substring(substring_index(NEW.data, '|', 1), length(substring_index(NEW.data, '|', 1 - 1)) + 1), '|', '') 
where callid = NEW.callid;
END IF;
 END
//
DELIMITER ;





Wednesday, August 11, 2010

Configuration of Digium TE110p with Asterisk With Difference E1 Provider

E1 is a physical layer protocol, like ethernet. It defines a 2Mbps link between two endpoints.

T1 is similar to E1. It is used in North America and is 1.544Mbps
A more in depth difference between the two can be found here

A J1 card is the Japanse version of a T1. (the tiny differences between T1 and J1 can be found here

Both T1 and E1 can be used to transmit data or voice, or a mixture of both.

For example: if an E1 is reserved for voice channels only, the 2mbit will be split into 32 64Kbps telephone channels. 30 of these channels can carry one telephone conversation each, and 2 carry signalling and timing information.

A t1 could carry 24 telephone channels, each of which can carry a telephone conversation.

Please note that in the states, its a common practice for carriers to offer fractional T1s, these have only some of the 24 channels provisoned.

Lets have a look at the supported audio operating modes:


Supported Audio Modes on E1/T1:

There are a number of protocols which can run on top of E1.
These protocols are grouped into 3 big subgroups, CAS, CCS, RBS.
Lets have a closer look on these subgroups:


a) CAS signalling

CAS stands for Channel Associated Signalling. Examples are FXS
loop start and E&M wink start. These protocols provide information such as the number that was called, and what state the call is in. They're limited in what information they can carry, and are slow to set up.

With this kind of signalling, a set of bits is used to replicate opening and closing the circuit (as if picking up the telephone receiver and pulsing digits on a rotary phone), or using tone signalling which is passed through on the voice circuits themselves

CAS is the original signaling system used by E1. In CAS, channel 16 is reserved for signaling. In recent years, the term RBS has been replaced by CAS which is now used to refer to bits that are associated with a specific channel whether it is in the T1 or E1 format.

Different subprotocols are:

- E&M

- Wink (this might be only RBS, if you know this for sure, please leave a comment.)
- Feature Group B
- Feature Group D

- FXO & FXS: this seems to only use CAS on E1's

- Ground Start
- Loop Start
- Loop Start with Disconnect Detect



CCS signalling

Common Channel signalling: A more recent kind of signalling, which resolves the problems associated with CAS signalling. In this kind of signalling, short messages are sent over the signalling channel, with more information about the call, including caller ID, type of transmission required, etc. etc.

CCS is used by either T1 or E1 and refers to a system that does not use a specific bit structure for signaling. Instead, all or part of a channel is used to pass messages between two systems to indicate how a channel is being used.

CCS is used by either T1 or E1 and refers to a system that does not use a specific bit structure for signaling. Instead, all or part of a channel is used to pass messages between two systems to indicate how a channel is being used. This type of system is commonly found in ISDN which uses a D channel to pass messages.

ISDN signalling and ss7 signalling are a subgroup of CCS signalling.

- ISDN (PRI CPE & PRI NET)

ISDN uses one channel (called the D channel) for signalling call information. On E1, this is one of the 2 signalling channels, leaving 30 channels for voice (called B channels). On T1, there aren't any spare signalling channels, so one of the voice channels is used, leaving 23 B channels for voice.

A PRI (Primary Rate ISDN) is simply an E1 or T1 with ISDN on top of it. ISDN gives fast, reliable call setup and hangup detection, and detailed information about the call. In the UK, PRI is also called ISDN30.

An important extension to ISDN is Q.SIG, which provides extra signalling information that is used when connecting PBX systems.

Currently, asterisk has limited support for Q.SIG, it can make and receive calls and retrieve some of the extra information.


- On E1, EuroISDN is the standard for ISDN signalling.

- On T1, there are different standards from different providers:
- NI1
- NI2
- 4ESS (AT&T)
- 5ESS (Lucent)
- DMS100


- SS7

RBS: Robbed Bit Signalling

RBS is the original signaling system used by T1 and provides either 2 or 4 signaling bits per channel depending on the multiframe format. In recent years, the term RBS has been replaced by CAS which is now used to refer to bits that are associated with a specific channel whether it is in the T1 or E1 format.

- E&M

- Wink
- Feature Group B
- Feature Group D


- FXO & FXS: this seems to only use RBS on T1's

- Ground Start
- Loop Start
- Loop Start with Disconnect Detect



Framing

AMI, B8ZS, and HDB3 are different types of line coding used in T1 and E1 communications systems. AMI stands for alternate mark inversion and is used in both T1 and E1 systems. B8ZS stands for Bipolar with 8 Zeros Substitution and is used in T1 systems while HDB3 stands for High-Density Bipolar 3 and is used in E1 systems.

- HDB3: High-Density Bipolar 3 -> E1 only
- AMI: Aternate Mark Inversion -> E1 and T1, the T1 version exists with both ESF (extended super frame) and SF (super frame)
- B8ZS: Bipolar with 8 Zeros Substitution -> T1 only, exists with both ESF (extended super frame) and SF (super frame)



What signalling and framing should i ask my carrier?



Timing or clock sources

A T1/E1 connection needs a timing device on one of both ends.
A T1/E1 line can be clocked internally or can be clocked by the telco.


Asterisk Compatible E1/T1 cards

available cards

Digium:

- TE110p: 1 port T1/E1 for use in 3.3 or 5 volt pci slots.
- TE205p: 2 port T1/E1 for use in 5 volt pci slots
- TE210p: 2 port T1/E1 for use in 3.3 volt pci slots
- TE405p: 4 port T1/E1 for use in 5 volt pci slots
- TE410p: 4 port T1/E1 for use in 3.3 volt pci slots
- TE406p: 2nd generation 4 port T1/E1 for use in 5 volt pci slots, with hardware DTMF recognition and echo cancellation. (now discontinued, but still supported)
- TE411p: 2nd generation 4 port T1/E1 for use in 3.3 volt pci slots, with hardware DTMF recognition and echo cancellation. (now discontinued, but still supported)
- TE407p: 3rd generation 4 port T1/E1 for use in 5 volt pci slots, with octasic hardware DTMF recognition and echo cancellation.
- TE412p: 3rd generation 4 port T1/E1 for use in 3.3 volt pci slots, with octasic hardware DTMF recognition and echo cancellation.

- Tormenta 2: Discontinued cards based on the open source project zapatatelephony
These cards were known as: Wildcard T100P, T400P, E100P, E400P

intel

- Dialogic D/41JCT-LS: quad t1/e1 board, requires additional (paid) drivers from digium to make it work.

sangoma

- A101: One port T1/E1 card
- A102 :Two port T1/E1 card
- A104: Four port T1/E1 card

varion

- V400P-E: 4 port E1 card, based on the open source zapata telephony project.
These are the same cards as the discontinued digium cards.

- V400P-T: 4 port E1 card, based on the open source zapata telephony project.
These are the same cards as the discontinued digium cards.

Eikon

- none public available yet.


What card should you pick ?

I recommend against using cards based on the tormenta project, they are way older and take up a lot more cpu. (and their development seems stalled).

The newest digium cards (TE406p and TE411p) as well as the latest firmware versions of the te405p and te410p are optimized for speed.

Only the digium TE406p and the digiun TE411p have hardware echo cancellation, causing a big difference in cpu usage. But this comes at a slightly higher cost.

If you need the 40% speed gain with on board echo cancellers, go for these cards, otherwise go for the cheaper te410p or te405p. (or the 1 or 2 port versions).

It is said on the mailinglists that the hardware echo canceller also has better quality than the echo cancellation done in software. (I can confirm nor deny this claim - it's based on a single source).



Asterisk E1/T1 channel drivers

There are two ways to get the E1/T1 cards to work:

First one is chan_zap (requires the zaptel kernel modules), this is recommended for all digium + sangoma cards.

The second one is chan_mISDN (requires the mISDN kernel patches)

This is probably only usefull for eicon cards. chan_misdn is written for BRI cards, but also supports some E1/T1 cards.

Building, installing and configuring asterisk with E1/T1 cards

We will only discuss using chan_zap for now (its the only recommended thing to do).


Tata IndiCom Provider

Cross cable with tata indicom PRI line

Few Things  need to Conform from Provider

  • check with your provider if CRC is on
  • signaling type
  • Cross Cable or not 

 Configuration In 
     zaptel.conf

   span=1,1,0,ccs,hdb3
   bchan=1-15,17-31
   dchan=16
   loadzone=uk
   defaultzone=uk 

   zapata.conf
   [trunkgroups]

   [channels]

   language=en
   context=from-zaptel
   switchtype=euroisdn
   pridialplan=unknown
   priindication=outofband
   usecallerid=yes
   hidecallerid=no
   callwaiting=yes
   usecallingpres=yes
   threewaycalling=yes
   transfer=yes
   cancallforward=yes
   callreturn=yes
   callgroup=1
   pickupgroup=1
   immediate=no
   echotraining=800
   echocancel=yes
   echocancelwhenbridged=no
   relaxdtmf=yes
   musiconhold=default
   immediate=no
   txgain=0.0
   rxgain=0.0
   group=1
   signalling=pri_cpe
   channel=>1-15,17-31
   overlapdial=yes 

Hardware Configuration for  TE110 digium card or Sangoma A101 card 

2 CPU dual core Xeon 2.6/3.0 Ghz
4 GB RAM
15 k RPM SAS 4 disks raid 10 or 2 disks raid 1 or single disk raid 0( for recordings) or SATA disk for no recordings
1000 mbps ethernet NIC

The motherboard should have a PCI 3.3v/5v slot depending on the card or you may need to get a PCI express card or a PCI riser card, order the card after u check the PCI slots on the board 



Airtel

E1 PRI working perfectly fine..


/etc/dahdi/system.conf

loadzone = uk
defaultzone = uk
span = 1,1,0,ccs,hdb3,crc4
bchan = 1-15,17-31
dchan = 16

/etc/asterisk/chan_dahdi.conf

[trunkgroups]

[channels]
context=airtel
switchtype=euroisdn
pridialplan=unknown
;prilocaldialplan=unknown
;overlapdial=yes
signalling=pri_cpe
;rxwink=300 ; Atlas seems to use long (250ms) winks
usecallerid=yes
hidecallerid=no
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
;transfer=yes
canpark=yes
cancallforward=yes
callreturn=yes
echocancel=no
echocancelwhenbridged=no
rxgain=0.0
txgain=0.0
group=1
inbanddisconnect=yes
callgroup=1
pickupgroup=1
immediate=no
channel => 1-15,17-31  

 


Friday, August 6, 2010

FTP Server Installation and Configuration In Linux Server

Linux comes with various ftp servers to setup FTP service such as:

  • proftpd - Versatile, virtual-hosting FTP daemon 
  • vsftpd - The Very Secure FTP Daemon
  • ftpd - FTP server
  • wu-ftpd - powerful and widely used FTP server
  • wzdftpd - A portable, modular, small and efficient ftp server
  • pure-ftpd - Pure-FTPd FTP server

Install and Configuration of vsftpd 

In centos 

yum install vsftpd 

Configure /etc/vsftpd/vsftpd.conf

# Allow anonymous FTP?
anonymous_enable=YES
...
# The directory which vsftpd will try to change
# into after an anonymous login. (Default = /var/ftp)
anon_root=/data/directory
...
# Uncomment this to allow local users to log in.
local_enable=YES
...
# Uncomment this to enable any form of FTP write command.
# (Needed even if you want local users to be able to upload files)
write_enable=YES
...
# Uncomment to allow the anonymous FTP user to upload files. This only
# has an effect if global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
...
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
...
# Activate logging of uploads/downloads.
xferlog_enable=YES
...
# You may override where the log file goes if you like.
# The default is shown below.
xferlog_file=/var/log/vsftpd.log
...
anon_root=/data/directory   the root directory that visitors will visit

  

FTP Security  

In /etc/vsftpd/ftpusers 

 For added security, you may restrict FTP access to certain users by adding them to the list of users in the /etc/vsftpd.ftpusers file. The VSFTPD package creates this file with a number of entries for privileged users that normally shouldn't have FTP access. As FTP doesn't encrypt passwords, thereby increasing the risk of data or passwords being compromised, it is a good idea to let these entries remain and add new entries for additional security

Anonymous Upload

If you want remote users to write data to your FTP server, then you should create a write-only directory within /var/ftp/pub. This will allow your users to upload but not access other files uploaded by other users

. The commands you need are:
# mkdir /var/ftp/pub/upload
# chmod 722 /var/ftp/pub/upload

FTP Greeting Banner

Change the default greeting banner in the vsftpd.conf file to make it harder for malicious users to determine the type of system you have. The directive in this file is. 

ftpd_banner= New Banner Here

Start VSFTP 

service vsftpd start

 

 

 


Thursday, August 5, 2010

Monitoring the Linux Server Using Nagios

 How to" install, configure and secure your monitoring server the most simply possible.

  • Download the nagios and plugins
  • Take care of the prerequisites
  • Create user and group for nagios
  • Install nagios
  • Configure the web interface
  • Compile and install nagios plugins
  • Start Nagios
  • Login to web interface

Download the nagios and plugins

from the website : http://www.nagios.org/download/core/thanks/

Take care of the prerequisites

yum install gcc gd

Create user and group for nagios

useradd nagios
groupadd nagios
usermod -G nagios nagios
usermod -G nagios apache
 

Install nagios

tar xvf nagios-3.x.x.tar.gz
cd nagios
/configure --with-command-group=nagios
make all
make install
make install-config
make install-commandmode

Configure the web interface.

make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Compile and install nagios plugins

tar xvf nagios-plugins-1.4.xx.tar.gz
cd nagios-plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

Start Nagios

chkconfig --add nagios
chkconfig nagios on
 
command line
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start

Login to web interface

http://localhost/nagios/

Configuration File located at /usr/local/nagios/etc/

  • nagios.cfg – This is the primary Nagios configuration file where lot of global parameters that controls the nagios can be defined.
  • cgi.cfg - This files has configuration information for nagios web interface.
  • resource.cfg – If you have to pass some sensitive information (username, password etc.) to a plugin to monitor a specific service, you can define them here. This file is readable only by nagios user and group.
Following are the other configuration files under /usr/local/nagios/etc/objects directory:

  • contacts.cfg: All the contacts who needs to be notified should be defined here. You can specify name, email address, what type of notifications they need to receive and what is the time period this particular contact should be receiving notifications etc.
  • commands.cfg – All the commands to check services are defined here. You can use $HOSTNAME$ and $HOSTADDRESS$ macro on the command execution that will substitute the corresponding hostname or host ip-address automatically.
  • timeperiods.cfg – Define the timeperiods. for e.g. if you want a service to be monitored only during the business hours, define a time period called businesshours and specify the hours that you would like to monitor.
  • templates.cfg – Multiple host or service definition that has similar characteristics can use a template, where all the common characteristics can be defined. Use template is a time saver.
  • localhost.cfg – Defines the monitoring for the local host. This is a sample configuration file that comes with nagios installation that you can use as a baseline to define other hosts that you would like to monitor.
  • printer.cfg – Sample config file for printer
  • switch.cfg – Sample config file for switch
  • windows.cfg – Sample config file for a windows machine

 

 

 

 

 

 

 

 

Wednesday, August 4, 2010

Asterisk Channels Chanspy and Barging for Manager To Monitor the Agents

Allows eavesdropping on a conversation on any specified channel (this is different from ZapBarge()/ZapScan() which are bound to Zap channels only). Note that this application only listens on single channels, rather than the conversation per se, even though it does capture incoming and outgoing audio on the channel.

Chanspy([][,])

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.  

Since 1.6 
  -b :Only spy on channels involved in a bridged call
   -d  :Override the typical numeric DTMF functionality and instead  use DTMF to switch between spy modes
            4 -spy mode
            5 -wispher mode
            6 -Bridge mode
 -g :Only spy on channels in which one or more of the groups listed ingrp            matches one or more groups from the SPYGROUP  variable set on the channel to be spied upon.

-n :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 contextbe used when searching for the name (i.e. if SIP/1000 is the channel being
           spied on and no mailbox is specified, then1000 will be used when searching for the name).
-q : Don't play a beep when beginning to spy on a channel, or speak the selected channel name.
-r :Record the session to the monitor spool directory. An optional base for the filename  may be specified. The default is chanspy.
-v : Adjust the initial volume in the range from -4  to 4. A negative value refers to a quieter setting.
-o:Only listen to audio coming from this channel
-X:Allow the user to exit ChanSpy to a valid single digit numeric extension in the current context or the context specified by the SPY_EXIT_CONTEXT channel variable. The name of the last channel that was spied on will be stored in the SPY_CHANNEL variable.
-s :Skip the playback of the channel type (i.e. SIP, IAX, etc) when speaking the selected channel name
-e :Enable enforced mode, so the spying channel can only monitor extensions whose name is in the ext
-B:Instead of whispering on a single channel barge in on both channels involved in the call.


exten => 007,1,ChanSpy(SIP/${EXTEN}|dq)