-
Notifications
You must be signed in to change notification settings - Fork 2
alochym01/user_directory_FS
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Testing version 0.1
debug community between freeswitch and http server:
http server and freeswitch run on same server
ngrep -W byline -d lo
Cach cai dat Freeswitch bang goi rpm
Cu phap cho lenh ln: ln –s source destination
1. freeswitch-1.0.6-1.i386.rpm
2. freeswitch-codec-passthru-g729-1.0.6-1.i386.rpm
3. freeswitch-devel-1.0.6-1.i386.rpm
4. freeswitch-lang-en-1.0.6-1.i386.rpm
5. freeswitch-lua-1.0.6-1.i386.rpm
6. freeswitch-sounds-en-us-callie-8000-1.0.18.noarch.rpm
7. freeswitch-sounds-music-8000-1.0.8-2.noarch.rpm
8. freeswitch-spidermonkey-1.0.6-1.i386.rpm
Buoc 1: cai dat HDH centos version 5.7
Buoc 2: cai dat cac goi dependency
• yum install -y alsa-lib curl libidn libogg libtheora libvorbis perl postgresql-libs unixODBC-libs
Buoc 3: cai dat freeswitch:
1. rpm -ivh freeswitch-1.0.6-1.i386.rpm freeswitch-devel-1.0.6-1.i386.rpm freeswitch-codec-passthru-g729-1.0.6-1.i386.rpm freeswitch-lang-en-1.0.6-1.i386.rpm freeswitch-lua-1.0.6-1.i386.rpm freeswitch-sounds-en-us-callie-8000-1.0.18.noarch.rpm freeswitch-sounds-music-8000-1.0.8-2.noarch.rpm freeswitch-spidermonkey-1.0.6-1.i386.rpm
Buoc 4: chkconfig –-add freeswitch
chkconfig –-level 345 freeswitch on
Buoc 5: chown freeswitch:daemon –R /opt
Buoc 6: reboot server
ktra coi freeswitch co tu start hay ko, cau lenh ktra:
1. netstat –nlp | grep 5060
2. ps –ef | grep freeswitch
3. /etc/init.d/freeswitch status
4. Check IO cua harddisk, network: iostats –n -1
Enable Freeswitch use mysql instead of sqlite
1: yum install unixODBC-devel mysql-connector-odbc mysql-server
2: edit file /etc/odbcinst.ini:
[MySQL]
Description = ODBC for MySQL
#check file libmyodbc3_r.so + libodbcmyS.so in the folder /usr/lib
Driver = /usr/lib/libmyodbc3_r.so
Setup = /usr/lib/libodbcmyS.so
Driver64 = /usr/lib64/libmyodbc3_r.so
Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1
3: edit file /etc/odbc.ini:
[freeswitch]
Driver = MySQL
SERVER = 127.0.0.1
PORT = 3306
DATABASE = freeswitch
OPTION = 67108864
Socket = /var/lib/mysql/mysql.sock
USER = test2 # insert your db username
PASSWORD = pass # insert your db password here
4: edit file /opt/freeswitch/conf/sip_profiles/internal.xml
<!--<param name="odbc-dsn" value="dsn:user:pass"/>--> change to <param name="odbc-dsn" value="freeswitch:test2:pass"/>
mysql> show tables;
+-------------------------------------+
| Tables_in_freeswitch |
+-------------------------------------+
| sip_authentication |
| sip_dialogs |
| sip_presence |
| sip_recovery |
| sip_registrations |
| sip_shared_appearance_dialogs |
| sip_shared_appearance_subscriptions |
| sip_subscriptions |
+-------------------------------------+
5: if you dont edit file /opt/freeswitch/conf/autoload_configs/switch.conf.xml and change the below line:
<!-- <param name="core-db-dsn" value="dsn:username:password" /> -->
<param name="core-db-dsn" value="freeswitch:test2:pass" />
[root@localhost freeswitch]# ls db/
call_limit.db core.db fifo.db sofia_reg_external.db sofia_reg_internal-ipv6.db voicemail_default.db
and your database will be the result as step 4
if you changed and your database look like below
mysql> show tables;
+-------------------------------------+
| Tables_in_freeswitch |
+-------------------------------------+
| aliases |
| calls |
| channels |
| complete |
| interfaces |
| nat |
| sip_authentication |
| sip_dialogs |
| sip_presence |
| sip_recovery |
| sip_registrations |
| sip_shared_appearance_dialogs |
| sip_shared_appearance_subscriptions |
| sip_subscriptions |
| tasks |
+-------------------------------------+
push CDR log into mysql:
1. create tables CDR to store cdr
CREATE TABLE cdr (
caller_id_name varchar(30) DEFAULT NULL,
caller_id_number varchar(30) DEFAULT NULL,
destination_number varchar(30) DEFAULT NULL,
context varchar(20) DEFAULT NULL,
start_stamp varchar(64) DEFAULT NULL,
answer_stamp varchar(64) DEFAULT NULL,
end_stamp varchar(64) DEFAULT NULL,
duration varchar(64) DEFAULT NULL,
billsec varchar(64) DEFAULT NULL,
hangup_cause varchar(50) DEFAULT NULL
)ENGINE=MyISAM;
2. run command:
2.1 in shell mode: fs_cli -x 'fsctl send_sighup'
2.2 command 'fsctl send_sighup in freeswitch mode
2.3 you can use the telnet IP of freeswitch port 8021 with pass ClueCon
3. write the bash script and python script to load the Master.csv.YY-MM-DD-Hour-Minite-second into mysql
mysql_db.py
import os
import time
#wait 30 second for the /opt/freeswitch/bin/fs_cli -x 'fsctl send_sighup' complete
time.sleep(30)
import MySQLdb as mysql
path = "/opt/freeswitch/log/cdr-csv/"
#list all file in path. dirList is a List object
dirList = os.listdir(path)
server = 'localhost'
user = 'test2'
passwd = 'pass'
database = 'freeswitch'
#connection to mysql
con = mysql.connect(server, user, passwd, database)
if(con):
print("Connect successfull")
else:
print("Connect not successfull")
#cursor of mysql connection
cur = con.cursor()
for i in dirList:
#path to file cdr-csv...
file_name = path+i
if(file_name != "/opt/freeswitch/log/cdr-csv/Master.csv"):
f = open(file_name, 'r')
for line in f:
a=line.split(',')
sql_statement = "INSERT INTO cdr(caller_id_name, caller_id_number, destination_number, context, start_stamp, answer_stamp, end_stamp, duration, billsec, hangup_cause) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
cur.execute(sql_statement,(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]))
f.close()
#delete file cdr
os.remove(file_name)
con.close()
4. create crontab to execute the step 2 + step 3 in 5min/1hour/1day
the script look like this:(test.sh) and set the test.sh can run via chmod +x test.sh
/opt/freeswitch/bin/fs_cli -x 'fsctl send_sighup'
python /opt/freeswitch/scripts/mysql_db.py
About
Freeswitch use mod_xml_curl to get user information in database
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published