Use sqlserver to store the call records of Asterisk

Source: Internet
Author: User

It is very easy to store the call records of Asterisk to MySQL, but it is also easy to store them to SQL Server.

First declare the environment: centos6.2 + asterisk 1.8.7.1 + freetds 0.91 + sqlserver 2008

1. Install rpmforge and epel sources

2. Install freetds:
Yum install freetds *

3. Configure and test freetds
VI/etc/freetds. conf
Example:
IP: Port mode:

 
[Sql2008] Host= 172.16.16.100Port= 1433TDS version= 8.0

The test is as follows:

Tsql-s sql2008-U sa-P Password

Database instance mode:

 
[Voipcdrsvr] Host= 172.16.16.101Instance=Sqlexpresstds version= 8.0

The test is as follows:

Tsql-s voipcdrsvr-U sa-P Password
4. Configure Asterisk
Clear cdr_odbc.conf
>/Etc/asterisk/cdr_odbc.conf
Edit cdr_tds.conf
VI/etc/asterisk/cdr_tds.conf

 
[Global] connection=Voipcdrsvrport= 1433Dbname=Mydbtable=Cdruser=Sapassword= Mypasswd

5. Create an sqlserver data table:

 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. Restart asterisk to take effect:

Asterisk-Rx "core restart now"

Okay, that's all. I hope it will help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.