用SqlServer存储Asterisk的呼叫记录
将asterisk的呼叫记录存入mysql很简单,其实存入SqlServer也同样容易。
首先声明下环境:CentOS6.2 + Asterisk 1.8.7.1 + Freetds 0.91 + SqlServer 2008
1、安装rpmforge源和epel源
2、安装freetds:
yum install freetds*
3、配置并测试freetds
vi /etc/freetds.conf
示例如下:
ip:port模式:
[SQL2008] host = 172.16.16.100 port = 1433 tds version = 8.0
测试如下:
tsql -S SQL2008 -U sa -P password
数据库实例模式:
[voipCdrSvr] host = 172.16.16.101 instance = sqlexpress tds version = 8.0
测试如下:
tsql -S voipCdrSvr -U sa -P password
4、配置Asterisk
清空cdr_odbc.conf
> /etc/asterisk/cdr_odbc.conf
编辑cdr_tds.conf
vi /etc/asterisk/cdr_tds.conf
[global] connection=voipCdrSvr port=1433 dbname=myDB table=cdr user=sa password=myPasswd
5、创建Sqlserver数据表:
CREATE TABLE cdr ( [accountcode] [varchar] (20) NULL , [src] [varchar] (80) NULL , [dst] [varchar] (80) NULL , [dcontext] [varchar] (80) NULL , [clid] [varchar] (80) NULL , [channel] [varchar] (80) NULL , [dstchannel] [varchar] (80) NULL , [lastapp] [varchar] (80) NULL , [lastdata] [varchar] (80) NULL , [start] [datetime] NULL , [answer] [datetime] NULL , [end] [datetime] NULL , [duration] [int] NULL , [billsec] [int] NULL , [disposition] [varchar] (20) NULL , [amaflags] [varchar] (16) NULL , [uniqueid] [varchar] (150) NULL , [userfield] [varchar] (256) NULL )
6、重启Asterisk生效:
asterisk -rx "core restart now"
好,就这些了,希望对你有帮助。