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>