I assume that freeswitch and MySQL are installed already.
1) First we will need to install unixodbc & libmyodbc, by running following command:
apt-get install unixodbc libmyodbc
2) Please update /etc/odbcinst.ini:
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1
3) In my example MySQL is running on same server where freeswitch, please change localhost to your ip-address if MySQL DB is on separate machine. DB name, username and password is freeswitch in my case, but you will need to update it accordingly. When you are ready with config, please save it to /etc/odbc.ini.
[freeswitch]
Description = MySQL connection to 'freeswitch' database
Driver = MySQL
Database = freeswitch
Server = localhost
USER = freeswitch
PASSWORD = freeswitch
Port = 3306
Socket = /var/run/mysqld/mysqld.sock
4) Now we need to test if you set-up ODBC correctly, please run echo "select 1" | isql -v freeswitch in shell, you should get something similar to what you see below:
5) Now we need to recompile freeswitch with mod_odbc_cdr. Go to freeswitch source category and add line event_handlers/mod_odbc_cdr on top of /usr/src/freeswitch/modules.conf(please update path accordingly if your freeswitch source directory is different):
8) Please update /usr/local/freeswitch/conf/autoload_configs/odbc_cdr.conf.xml accordingly so it points to MySQL DB(line No4). In line no 4 freeswitch is connection name or value in square brackets in first line of /etc/odbc.ini:
<configuration name="odbc_cdr.conf"description="ODBC CDR Configuration">
<settings>
<!-- <param name="odbc-dsn"value="database:username:password"/> -->
<param name="odbc-dsn"value="odbc://freeswitch"/>
<!-- global value can be "a-leg", "b-leg", "both"(default is "both") -->
<param name="log-leg"value="both"/>
<!-- value can be "always", "never", "on-db-fail" -->
<param name="write-csv"value="on-db-fail"/>
<!-- location to store csv copy of CDR -->
<param name="csv-path"value="/usr/local/freeswitch/log/odbc_cdr"/>
<!-- if"csv-path-on-fail" is set, failed INSERTs will be placed here as CSV files otherwise they will be placed in"csv-path" -->
<param name="csv-path-on-fail"value="/usr/local/freeswitch/log/odbc_cdr/failed"/>
<!-- dump SQL statement after leg ends -->
<param name="debug-sql"value="true"/>
</settings>
<tables>
<!-- only a-legs will be inserted into this table -->
<table name="cdr_table_a_leg" log-leg="a-leg">
<field name="CallId" chan-var-name="call_uuid"/>
<field name="orig_id" chan-var-name="uuid"/>
<field name="term_id" chan-var-name="sip_call_id"/>
<field name="ClientId" chan-var-name="uuid"/>
<field name="IP" chan-var-name="sip_network_ip"/>
<field name="IPInternal" chan-var-name="sip_via_host"/>
<field name="CODEC" chan-var-name="read_codec"/>
<field name="directGateway" chan-var-name="sip_req_host"/>
<field name="redirectGateway" chan-var-name="sip_redirect_contact_host_0"/>
<field name="CallerID" chan-var-name="sip_from_user"/>
<field name="TelNumber" chan-var-name="sip_req_user"/>
<field name="TelNumberFull" chan-var-name="sip_to_user"/>
<field name="sip_endpoint_disposition" chan-var-name="endpoint_disposition"/>
<field name="sip_current_application" chan-var-name="current_application"/>
</table>
<!-- only b-legs will be inserted into this table -->
<table name="cdr_table_b_leg" log-leg="b-leg">
<field name="CallId" chan-var-name="call_uuid"/>
<field name="orig_id" chan-var-name="uuid"/>
<field name="term_id" chan-var-name="sip_call_id"/>
<field name="ClientId" chan-var-name="uuid"/>
<field name="IP" chan-var-name="sip_network_ip"/>
<field name="IPInternal" chan-var-name="sip_via_host"/>
<field name="CODEC" chan-var-name="read_codec"/>
<field name="directGateway" chan-var-name="sip_req_host"/>
<field name="redirectGateway" chan-var-name="sip_redirect_contact_host_0"/>
<field name="CallerID" chan-var-name="sip_from_user"/>
<field name="TelNumber" chan-var-name="sip_req_user"/>
<field name="TelNumberFull" chan-var-name="sip_to_user"/>
<field name="sip_endpoint_disposition" chan-var-name="endpoint_disposition"/>
<field name="sip_current_application" chan-var-name="current_application"/>
</table>
<!-- both legs will be inserted into this table -->
<table name="cdr_table_both">
<field name="CallId" chan-var-name="uuid"/>
<field name="orig_id" chan-var-name="Caller-Unique-ID"/>
<field name="TEST_id" chan-var-name="sip_from_uri"/>
</table>
</tables>
</configuration>
9) Please enable auto-load of mod_odbc_cdr. For this you need to edit /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml and add <load module="mod_odbc_cdr"/> on top of <load module="mod_cdr_csv"/>. In my minimal set-up it looks in following way(line No12):
11) Please restart freeswitch: service freeswitch restart
12) On this point you can check if module mod_odbc_cdr loaded. Please run following command in freeswitch CLI:
module_exists mod_odbc_cdr
If everything is ok, you will get following output:
13) On this point you CDRs should be written to MySQL DB, if somehow you still do not get CDRs in DB, you need to check /usr/local/freeswitch/log/freeswitch.log for errors or any other hints. Keep in mind that you might need to add some additional fields to DB and update odbc_cdr.conf.xml accordingly. Please take a closer look on data type used in CDRs table, probably it is not optimal and you might need to update it.
please refer below link
http://blog.volunge.net/jekyll/update/2016/02/16/freeswitch-mysql-CDRs.html
Freeswitch does not install sounds by default. By using below command default sounds will be loaded/installed.
make all cd-sounds-install cd-moh-install
For installing a module follow below steps(example mod_shout). Enable module in build --> modules.conf (mod_shout,mod_shell_stream,mod_http_cache)
Configure/Make --->./configure && make install
Enable module in runtime ---> In /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml file uncomment <load module="mod_shout"/>
Load the Module ---> load mod_shout
check module loaded/not in CLI ---> module_exists mod_shout {returns true if exists else false}.
To check if there are any new modules execute:
diff build/modules.conf.in modules.conf
If a previously disabled module is now enabled, or there is a requirement to rebuild a single module, execute the following (replace mod_name with the name of the module to build):
autoload_configs: It contains configuration information for all the core modules and these configuration files will automatically load into freeswitch. dialplan: This is the place where we write dialplans. There are some example dialplans exists. directory: It contains all users that may register and use freeswitch as their PBX. jingle_profiles : This is a module which handles XMPP. lang: It tells FS in which language to say the like currency etc. mrcp_profiles: MRCP is used to allow freeswitch to use speech recognition and TTS sip_profiles: Tells FS how to talk sip. Each profile has it's own port.
2. vi ${Prefix}/conf/directory/default/newuser.xml and change 1000 to newuser.
3. usercontext parameter is used to connect to dialplan. usercontext parameter value is default. we can change this to any but create that in dialplan.
4. create a dialplan in ${Prefix}/conf/dialplan/default.xml by seeing the example one.
bridge local SIP: <action application="bridge" data="user/${destination_number}"/>
Group Call: ring all the members in a group.
make a group in ${Prefix}/conf/directory/default.xml
<group name="support"> <users> <user id="1001" type="pointer"/> <user id="1004" type="pointer"/> <user id="1003" type="pointer"/> </users> </group>
2. create a external profile as gateway as below open sip_profiles/external/onsip-trunk.xml a file
add below lines <include> <gateway name="siptrunk"> <param name="username" value="siptrunk"/> <param name="password" value="123456"/> <param name="proxy" value="domain.com:5080"/> <param name="register-proxy" value="domain.com:5080"/> <param name="register" value="false"/> <param name="register-transport" value="udp"/> <!--How many seconds before a retry when a failure or timeout occurs --> <param name="retry-seconds" value="30"/> <!--Use the callerid of an inbound call in the from field on outbound calls via this gateway --> <param name="caller-id-in-from" value="false"/> <param name="from-domain" value="domain.com"/> <param name="extension-in-contact" value="true"/> <param name="liberal-dtmf" value="true"/> </gateway> </include>
3.reload the external profile
sofia profile external restart.
4. check the gateway with below command
sofia status
5. Make a dialplan with gateway
<extension name="domain.com"> <!-- The following line detects 11 digit outbound calls --> <condition field="destination_number" expression="^(\d{11})$"> <!-- This sets the outbound gateway as "siptrunk" , which was defined in your OnSIP Trunking user profile as the "gateway name" parameter. We've also appended the "000" outbound prefix to the dialed number.--> <action application="bridge" data="sofia/gateway/onsip-trunk.com/000$1"/> </condition> </extension>
ERROR[4599]: cdr_csv.c:237 csv_log: Unable to re-open master file /var/log/asterisk//cdr-csv//Master.csv : Read-only file system
Check the disk space using df -h if everything is fine try to restart
When suddenly permission issue received try to restart the machine once. After restart everything works fine it is ok otherwise do the following
Goautodial/vicidial runs asterisk in root permission only. You can safely ignore those warnings. To fix them, ran the following and reboot:
1. chkconfig --level 2345 asterisk off This turns off the default system Asterisk startup scripts which runs Asterisk as user Asterisk (that's why permission denied in /var/lib/asterisk/astdb). The default GOautodial Asterisk startup script is ran automatically if this is disabled.
First Check the disk space using df -h . If everything fine try to restart.
When suddenly permission issue received try to restart the machine once.
After restart everything works fine it is ok otherwise
do the following
Goautodial/vicidial runs asterisk in root permission only.
You can safely ignore those warnings. To fix them, ran the following and reboot:
1. chkconfig --level 2345 asterisk off
This turns off the default system Asterisk startup scripts which runs Asterisk as user Asterisk (that's why permission denied in /var/lib/asterisk/astdb). The default GOautodial Asterisk startup script is ran automatically if this is disabled.
Vicidial scratch installation in Centos 6.5 , with asterisk 1.8, latest dahdi and latest SVN version
Steps to install VICIDIAL SETUP 1. Install the CENTOS2. Install all the dependencies like update and pre requisites3. asterisk , Dahdi ,libpri installation4. vicidial installation5. Final Touch Step 1. Install the CENTOS The Centos 6.X can be download from the following Linkhttp://wiki.centos.org/Download Centos 6.X installation steps can be found from following Linkhttp://www.tecmint.com/centos-6-5-installation-guide-with-screenshots/ Disable the SELINUX To disable selinx open the below file and change parameter SELINUX to disabled vi /etc/selinux/config # This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - SELinux is fully disabled.SELINUX=disabled# SELINUXTYPE= type of policy in use. Possible values are:# targeted - Only targeted network daemons are protected.# strict - Full SELinux protection.SELINUXTYPE=targeted # SETLOCALDEFS= Check local definition changes SETLOCALDEFS=0 Stop Firewall/IP tables iptables -Fservice iptables saveservice iptables stop update the OS yum -y update After doing the changes reboot the machine once Reboot Step 2. Install all the dependencies,prerequisites Perl module Dependencies yum
install gcc gcc-c++ php php-devel php-gd gd-devel php-mbstring
php-mcrypt php-imap php-ldap php-mysql php-odbc php-pear php-xml
php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick libxml2
libxml2-devel httpd libpcap libpcap-devel ncurses ncurses-devel screen
sox mysql-server mysql-devel ntp kernel-devel mutt Setup Mysql
/etc/init.d/mysqld start
mysql_secure_installation
chkconfig mysqld on
service mysqld stop
cp /etc/my.cnf /etc/my.cnf.original
echo "" > /etc/my.cnf
vi /etc/my.cnf
; copy the below config to this file.
yum install perl-CPAN
yum install perl-YAMLperl -MCPAN -e shell ; just press
enter for all the questions.
You will then go through CPAN setup, just hit
ENTER for most prompts except
for the mirrors list, you will want to select at least 4 mirrors
yes for manual configuration
enter for the next 18 prompts
for the "make
install" option, it's a good idea to add UNINST=1
enter for the next 4 prompts
select your continent and country
select a few cpan mirrors
enter for the next 2 prompts
Once you see the cpan> prompt
you can begin installing modules.
install CPAN::Meta::Requirements
install CPAN
reload cpan
install YAML
install MD5
install Digest::MD5
install Digest::SHA1
install readline
install Bundle::CPAN
reload cpan
install DBI
force install DBD::mysql
install Net::Telnet
install Time::HiRes
install Net::Server
install Switch
install Mail::Sendmail
install Unicode::Map
install Jcode
install Spreadsheet::WriteExcel
install OLE::Storage_Lite
install Proc::ProcessTable
install IO::Scalar
install Spreadsheet::ParseExcel
install Curses
install Getopt::Long
install Net::Domain
install Term::ReadKey
install Term::ANSIColor
install Spreadsheet::XLSX
install Spreadsheet::Read
install LWP::UserAgent
install HTML::Entities
install HTML::Strip
install HTML::FormatText
install HTML::TreeBuilder
install Time::Local
install MIME::Decoder
install Mail::POP3Client
install Mail::IMAPClient
install Mail::Message
install IO::Socket::SSL
install MIME::Base64
install MIME::QuotedPrint
install Crypt::Eksblowfish::Bcrypt
quit
In the end, I usually run all these commands once
again to make sure its all installed. and make sure you get following output for each module
cpan> install Mail::Message
Mail::Message is up to date (2.115).
cpan> install MIME::QuotedPrint
MIME::QuotedPrint is up to date (3.13).
Installing
the Asterisk-Perl module
cd /usr/src
wget http://download.vicidial.com/required-apps/asterisk-perl-0.08.tar.gz
tar -zxf asterisk-perl-0.08.tar.gz
cd asterisk-perl-0.08
perl Makefile.PL
make allmake install
Installing
additional software from source
Next, you will download, compile and install the
following software.
lame
ttyload
iftop
mtop
mytop
htop
sipsak
ploticus
LAME
LAME is an MP3 encoder used to convert audio files from WAV to MP3. Some prefer GSM usually, but others have standardized on MP3 so you would need this utility to be loaded to use that option.
cd /usr/src
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar -zxf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure
make
make install
SOX:
SoX is a cross-platform
command line utility that can convert various formats of computer audio files
in to other formats.
cd /usr/src
wget http://downloads.sourceforge.net/project/sox/sox/14.4.1/sox-14.4.1.tar.gz
tar -zxf sox-14.4.1.tar.gz
cd sox-14.4.1
./configure
make -s
make install
TTYLOAD:
ttyload is a simple
terminal application that shows the processor load in a graphical time-based
scrolling graph. I use it to view how loaded the system is and it visualizes
load spikes very well.
cd /usr/src
wget http://download.vicidial.com/required-apps/ttyload-0.5.tar.gz
tar -xvzf ttyload-0.5.tar.gz
cd ttyload-0.5
nano ttyload.h
insert this #include directive just above the #define
directives, then save and close the ttyload.h file
#include <time.h>
make
ln -s /usr/src/ttyload-0.5/ttyload /usr/bin/ttyload
IFTOP:
iftop is a good console
bandwidth visualization tool that shows you active connections, where they are
going to/from and how much of your precious bandwidth they are using.
mytop is is an optional
utility for monitoring the threads and overall performance of mysqlNote: the root mysql password must be blank before installing this
cd /usr/src
wget http://jeremy.zawodny.com/mysql/mytop/mytop-1.6.tar.gz
tar -zxf mytop-1.6.tar.gz
cd mytop-1.6
perl Makefile.PL
make
make testmake install
HTOP:
htop is an interactive
process viewer for Linux
cd /usr/src
wget http://downloads.sourceforge.net/project/htop/htop/1.0.2/htop-1.0.2.tar.gz
tar -zxf htop-1.0.2.tar.gz
cd htop-1.0.2
./configure
makemake install
SIPSAK:
sipsak is an optional
utility that VICIDIAL can use to send messages to an agent's SIP-based
phone(like the Snom 320) to display text on their LCD screen.
cd /usr/src
wget http://download.vicidial.com/required-apps/sipsak-0.9.6-1.tar.gz
tar -zxf sipsak-0.9.6-1.tar.gz
cd sipsak-0.9.6
./configure
make
make install
/usr/local/bin/sipsak --version
PLOTICUS:
ploticus is a free graph
creation package that allows you to create line graphs within PNG files simply
by creating a config file and a data file. ViciDial uses this package to
generate server performance graphs that can be displayed real-time within the
ViciDial reports page.
cd /usr/src wget http://downloads.sourceforge.net/project/ploticus/ploticus/2.42/ploticus242_src.tar.gz tar -zxf ploticus242_src.tar.gz cd ploticus242/src/ make clean make make install mkdir -p /var/www/html/vicidial/ploticus/ cp pl /var/www/html/vicidial/ploticus/
eAccelerator :
cd /usr/src wget http://downloads.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip unzip eaccelerator-0.9.6.1.zip cd eaccelerator-0.9.6.1 export PHP_PREFIX="/usr" $PHP_PREFIX/bin/phpize ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config make
make install
Configure php.ini
vi /etc/php.ini
Change the following values in your php.ini file.
Customize the date.timezone so you don't end up with a bunch of php errors complaining about it not being defined.
error_reporting = E_ALL & ~E_NOTICE
memory_limit = 48M
short_open_tag = On
max_execution_time = 330
max_input_time = 360
post_max_size = 48M
upload_max_filesize = 42M
default_socket_timeout = 360
date.timezone = Asia/Kolkata
Add the following lines to the dynamic extensions section of php.ini:
Note: For CentOS 32-bit, use this below: zend_extension="/usr/lib/php/modules/eaccelerator.so"
To enable web browsing of Recordings on Asterisk server, add the below line at last line of httpd.conf
Alias /RECORDINGS/ "/var/spool/asterisk/monitorDONE/"
<Directory "/var/spool/asterisk/monitorDONE"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all <files *.mp3> Forcetype application/forcedownload </files> </Directory>
Restart the Apache web server to apply the changes
service httpd restart
chkconfig httpd on
Installing
Asterisk
Any time you upgrade the Linux kernel you must recompile/install
dahdi for the new kernel.
Asterisk must be compiled with dahdi support.
Note: The install MUST be done in the following order:
Minor note: dahdi-linux-complete-current.tar.gz
and libpri-1.4-current.tar.gz may contain an updated version than what I
am currently using, therefore the directory names may be different than shown
below.
mkdir /usr/src/asterisk
cd /usr/src/asterisk
wget http://download.vicidial.com/required-apps/asterisk-1.8.23.0-vici.tar.gz
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
tar -zxf asterisk-1.8.23.0-vici.tar.gz
tar -zxf dahdi-linux-complete-current.tar.gz
tar -zxf libpri-1.4-current.tar.gz
cd ../dahdi-linux-complete-2.9.1.1+2.9.1
make clean
make all
make install
make config
cd ../../libpri-1.4.15
make clean
make
make install
cd ../asterisk-1.8.23.0
./configure
make clean
make
make install
make samples
cp /usr/src/asterisk/asterisk-1.8.23.0/contrib/init.d/rc.redhat.asterisk
/etc/init.d/asterisk
chkconfig asterisk on
service dahdi restart
chkconfig dahdi on
modprobe dahdi
cd /var/lib/asterisk/sounds
tar -zxf /usr/src/asterisk-core-sounds-en-gsm-current.tar.gz
tar -zxf /usr/src/asterisk-core-sounds-en-ulaw-current.tar.gz
tar -zxf /usr/src/asterisk-core-sounds-en-wav-current.tar.gz
tar -zxf /usr/src/asterisk-extra-sounds-en-gsm-current.tar.gz
tar -zxf /usr/src/asterisk-extra-sounds-en-ulaw-current.tar.gz
tar -zxf /usr/src/asterisk-extra-sounds-en-wav-current.tar.gz
cd /var/lib/asterisk/mohmp3
tar -zxf /usr/src/asterisk-moh-opsound-gsm-current.tar.gz
tar -zxf /usr/src/asterisk-moh-opsound-ulaw-current.tar.gz
tar -zxf /usr/src/asterisk-moh-opsound-wav-current.tar.gz
rm -f CHANGES*
rm -f LICENSE*
rm -f CREDITS*
First, login to mysql to
create the database, add a couple users and assign privileges.
mysql -u root –p
Enter these MySQL commands:
CREATE DATABASE `asterisk`
DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER
'cron'@'localhost' IDENTIFIED BY '1234';
GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES on asterisk.* TO cron@'%'
IDENTIFIED BY '1234';
GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES on asterisk.* TO cron@localhost
IDENTIFIED BY '1234';
GRANT RELOAD ON *.* TO cron@'%';
GRANT RELOAD ON *.* TO cron@localhost;
flush privileges;
quit
I am going to install the latest 2.x SVN trunk which
happens to be version 2.8 at the time of writing this guide
mkdir
/usr/src/astguiclient
cd /usr/src/astguiclient
svn checkout svn://svn.eflo.net:3690/agc_2-X/trunk
cd trunk
perl install.pl
You will have to define various things like IP address of
the server
It will also ask you where is the web root, use /var/www/html
Leave the other login settings as-is unless you already
know how to update the database and other asterisk config files.
Import sample data
Login to mysql to run some commands
mysql -u root -p
Enter these MySQL
commands:
mysql>SET GLOBAL
connect_timeout=60;
mysql>use asterisk;
2. Failed to start dahdi.service: Unit dahdi.service failed to load: No such file or directory. yum install kernel-devel There is an issue in the 2.11 releases where "make config" no longer functions as expected in DAHDI tools. For a temporary work around either install a version older than 2.11.0 or, in dahdi tools, run "make install-config" dmesg dahdi_genconf -v dahdi_cfg -v
/etc/init.d/dahdi restart 3. Asterisk not reloading asterisk is not reloaded automatically whenever there is a change in Vicidial gui.
check the screen
screen -ls
There are screens on:
4467.ASTVDadapt (Detached)
4588.ASTsend (Detached)
3430.astshell20110326150232 (Detached)
4591.ASTlisten (Detached)
3435.asterisk (Detached)
3558.ASTfastlog (Detached)
4594.ASTVDauto (Detached)
4597.ASTVDremote (Detached)
4455.ASTupdate (Detached)
9 Sockets in /var/run/screen/S-root. If it is ok. then check the below things check the /etc/rc3.d/ directory for S90asterisk file. If it exists try to move to K90asterisk cd /etc/rc3.d/ ls mv S90asterisk K90asterisk Explanation: I had a startup script S90asterisk in my /etc/rc3.d/ directory which was starting Asterisk on boot. I also had a "sleep 20; start_asterisk_boot.pl" in my /etc/rc.local which starts Asterisk the Vicidial way. All I did is disable the S90asterisk by renaming to K90asterisk. So now, this script does not start Asterisk on boot, but instead the one in rc.local does. It also starts up all the screens in the correct manner. For all who don't know how to troubleshoot with screen (like I did not): The "screen -r" shows all current screen sessions. "screen -x ID" fires up a screen. You should see the Asterisk console like in "asterisk -r" when you log on to the Asterisk screen session.
I am able to see the Asterisk console on its screen session. Any changes made to the configuration are being reflected in the config files AND Asterisk is being reloaded every time a change is made.