This document provides instructions for configuring Asterisk to store Call Detail Records (CDRs) in a Microsoft SQL Server database using either the cdr_odbc or cdr_tds backends. It describes compiling and configuring the necessary FreeTDS and ODBC packages, modifying the Asterisk configuration, and creating the required CDR table in the MSSQL database.
This document provides instructions for configuring Asterisk to store Call Detail Records (CDRs) in a Microsoft SQL Server database using either the cdr_odbc or cdr_tds backends. It describes compiling and configuring the necessary FreeTDS and ODBC packages, modifying the Asterisk configuration, and creating the required CDR table in the MSSQL database.
This document provides instructions for configuring Asterisk to store Call Detail Records (CDRs) in a Microsoft SQL Server database using either the cdr_odbc or cdr_tds backends. It describes compiling and configuring the necessary FreeTDS and ODBC packages, modifying the Asterisk configuration, and creating the required CDR table in the MSSQL database.
This document provides instructions for configuring Asterisk to store Call Detail Records (CDRs) in a Microsoft SQL Server database using either the cdr_odbc or cdr_tds backends. It describes compiling and configuring the necessary FreeTDS and ODBC packages, modifying the Asterisk configuration, and creating the required CDR table in the MSSQL database.
The document discusses two methods for storing Call Detail Records (CDRs) from Asterisk in a Microsoft SQL Server database: using cdr_odbc which utilizes unixODBC and FreeTDS, or directly using cdr_tds which only requires FreeTDS. It provides configuration instructions and examples for both methods.
CDRs can be stored in MSSQL using Asterisk in two ways - using cdr_odbc which utilizes unixODBC and FreeTDS, or directly using cdr_tds which only requires FreeTDS. The document provides details on compiling, configuring, and using both methods.
The steps include compiling Asterisk with ODBC support, installing and configuring unixODBC and FreeTDS, setting up odbc.ini and cdr_odbc.conf files, and creating the 'cdr' table in the MSSQL database. The document provides examples of working configuration files.
Created by Malcolm Davenport, last modified by Sean Bright on May 04, 2012
Asterisk Project / / CDR Storage Backends
MSSQL CDR Backend Asterisk can currently store CDRs into a Microsoft SQL Server database in two different ways: cdr_odbc or cdr_tds Call Data Records can be stored using unixODBC (which requires the FreeTDS package) cdr_odbc or directly by using just the FreeTDS package cdr_tds. The following provide some examples known to get asterisk working with mssql. ODBC using cdr_odbc Compile, configure, and install the latest unixODBC package: tar -zxvf unixODBC-2.2.9.tar.gz && cd unixODBC-2.2.9 && ./configure --sysconfdir=/etc --prefix=/usr --disable-gui && make && make install Compile, configure, and install the latest FreeTDS package: tar -zxvf freetds-0.62.4.tar.gz && cd freetds-0.62.4 && ./configure --prefix=/usr --with-tdsver=7.0 \ --with-unixodbc=/usr/lib && make && make install Compile, or recompile, asterisk so that it will now add support for cdr_odbc. make clean && ./configure --with-odbc && make update && make && make install Setup odbc configuration files. These are working examples from my system. You will need to modify for your setup. You are not required to store usernames or passwords here. /etc/odbcinst.ini Only choose one db connector. [FreeTDS] Description = FreeTDS ODBC driver for MSSQL Driver = /usr/lib/libtdsodbc.so Setup = /usr/lib/libtdsS.so FileUsage = 1 /etc/odbc.ini [MSSQL-asterisk] description = Asterisk ODBC for MSSQL driver = FreeTDS server = 192.168.1.25 port = 1433 database = voipdb tds_version = 7.0 language = us_english Now set up cdr_odbc configuration files. These are working samples from my system. You will need to modify for your setup. Define your usernames and passwords here, secure file as well. /etc/asterisk/cdr_odbc.conf [global] dsn=MSSQL-asterisk username=voipdbuser password=voipdbpass loguniqueid=yes Only install one database connector. Do not confuse asterisk by using both ODBC (cdr_odbc) and FreeTDS (cdr_tds). This command will erase the contents of cdr_tds.conf [ -f /etc/asterisk/cdr_tds.conf ] > /etc/asterisk/cdr_tds.conf unixODBC requires the freeTDS package, but asterisk does not call freeTDS directly. And finally, create the 'cdr' table in your mssql database. CREATE TABLE cdr ( [calldate] [datetime] NOT NULL , [clid] [varchar] (80) NOT NULL , [src] [varchar] (80) NOT NULL , [dst] [varchar] (80) NOT NULL , [dcontext] [varchar] (80) NOT NULL , [channel] [varchar] (80) NOT NULL , [dstchannel] [varchar] (80) NOT NULL , [lastapp] [varchar] (80) NOT NULL , [lastdata] [varchar] (80) NOT NULL , [duration] [int] NOT NULL , [billsec] [int] NOT NULL , [disposition] [varchar] (45) NOT NULL , [amaflags] [int] NOT NULL , [accountcode] [varchar] (20) NOT NULL , [uniqueid] [varchar] (150) NOT NULL , [userfield] [varchar] (255) NOT NULL ) Start asterisk in verbose mode. You should see that asterisk logs a connection to the database and will now record every call to the database when it's complete. TDS, using cdr_tds Compile, configure, and install the latest FreeTDS package: tar -zxvf freetds-0.62.4.tar.gz && cd freetds-0.62.4 && ./configure --prefix=/usr --with-tdsver=7.0 make && make install Compile, or recompile, asterisk so that it will now add support for cdr_tds. make clean && ./configure --with-tds && make update && make && make install Only install one database connector. Do not confuse asterisk by using both ODBC (cdr_odbc) and FreeTDS (cdr_tds). This Setup cdr_tds configuration files. These are working samples from my system. You will need to modify for your setup. Define your usernames and passwords here, secure file as well. /etc/asterisk/cdr_tds.conf [global] hostname=192.168.1.25 port=1433 dbname=voipdb user=voipdbuser password=voipdpass charset=BIG5 And finally, create the 'cdr' table in your mssql database. 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 ) Start asterisk in verbose mode. You should see that asterisk logs a connection to the database and will now record every call to the database when it's complete. command will erase the contents of cdr_odbc.conf [ -f /etc/asterisk/cdr_odbc.conf ] > /etc/asterisk/cdr_odbc.conf 1 Comment SIbghatullah Sheikh error was --with-unixodbc unknown variable while using configure for freetds tar -zxvf freetds-0.91.tar.gz && cd freetds-0.91 && ./configure --prefix=/usr --with-tdsver=8.0 --with- unixodbc=/usr/src/unixODBC-2.3.0 && make && make install (note: -withunixodbc=(path to where unixodbc is installed) This worked for me !!