1 Call data records can be stored in many different databases or even CSV text.
3 MSSQL: Asterisk can currently store CDRs into an MSSQL database in
4 two different ways: cdr_odbc.c or cdr_tds.c
6 Call Data Records can be stored using unixODBC (which requires
7 the FreeTDS package) [cdr_odbc.c] or directly by using just the
8 FreeTDS package [cdr_tds.c] The following provide some
9 examples known to get asterisk working with mssql.
10 NOTE: Only choose one db connector.
13 Compile, configure, and install the latest unixODBC package:
14 tar -zxvf unixODBC-2.2.9.tar.gz &&
16 ./configure --sysconfdir=/etc --prefix=/usr --disable-gui &&
20 Compile, configure, and install the latest FreeTDS package:
21 tar -zxvf freetds-0.62.4.tar.gz &&
23 ./configure --prefix=/usr --with-tdsver=7.0 \
24 --with-unixodbc=/usr/lib &&
28 Compile, or recompile, asterisk so that it will now add support
36 Setup odbc configuration files. These are working examples
37 from my system. You will need to modify for your setup.
38 You are not required to store usernames or passwords here.
42 Description = FreeTDS ODBC driver for MSSQL
43 Driver = /usr/lib/libtdsodbc.so
44 Setup = /usr/lib/libtdsS.so
49 description = Asterisk ODBC for MSSQL
57 Only install one database connector. Do not confuse asterisk
58 by using both ODBC (cdr_odbc.c) and FreeTDS (cdr_tds.c).
59 This command will erase the contents of cdr_tds.conf
61 [ -f /etc/asterisk/cdr_tds.conf ] > /etc/asterisk/cdr_tds.conf
63 NOTE: unixODBC requires the freeTDS package, but asterisk does
64 not call freeTDS directly.
66 Setup cdr_odbc configuration files. These are working samples
67 from my system. You will need to modify for your setup. Define
68 your usernames and passwords here, secure file as well.
70 /etc/asterisk/cdr_odbc.conf
77 And finally, create the 'cdr' table in your mssql database.
80 [calldate] [datetime] NOT NULL ,
81 [clid] [varchar] (80) NOT NULL ,
82 [src] [varchar] (80) NOT NULL ,
83 [dst] [varchar] (80) NOT NULL ,
84 [dcontext] [varchar] (80) NOT NULL ,
85 [channel] [varchar] (80) NOT NULL ,
86 [dstchannel] [varchar] (80) NOT NULL ,
87 [lastapp] [varchar] (80) NOT NULL ,
88 [lastdata] [varchar] (80) NOT NULL ,
89 [duration] [int] NOT NULL ,
90 [billsec] [int] NOT NULL ,
91 [disposition] [varchar] (45) NOT NULL ,
92 [amaflags] [int] NOT NULL ,
93 [accountcode] [varchar] (20) NOT NULL ,
94 [uniqueid] [varchar] (32) NOT NULL ,
95 [userfield] [varchar] (255) NOT NULL
98 Start asterisk in verbose mode, you should see that asterisk
99 logs a connection to the database and will now record every
100 call to the database when it's complete.
103 Compile, configure, and install the latest FreeTDS package:
104 tar -zxvf freetds-0.62.4.tar.gz &&
106 ./configure --prefix=/usr --with-tdsver=7.0
110 Compile, or recompile, asterisk so that it will now add support
118 Only install one database connector. Do not confuse asterisk
119 by using both ODBC (cdr_odbc.c) and FreeTDS (cdr_tds.c).
120 This command will erase the contents of cdr_odbc.conf
122 [ -f /etc/asterisk/cdr_odbc.conf ] > /etc/asterisk/cdr_odbc.conf
124 Setup cdr_tds configuration files. These are working samples
125 from my system. You will need to modify for your setup. Define
126 your usernames and passwords here, secure file as well.
128 /etc/asterisk/cdr_tds.conf
130 hostname=192.168.1.25
137 And finally, create the 'cdr' table in your mssql database.
140 [accountcode] [varchar] (20) NULL ,
141 [src] [varchar] (80) NULL ,
142 [dst] [varchar] (80) NULL ,
143 [dcontext] [varchar] (80) NULL ,
144 [clid] [varchar] (80) NULL ,
145 [channel] [varchar] (80) NULL ,
146 [dstchannel] [varchar] (80) NULL ,
147 [lastapp] [varchar] (80) NULL ,
148 [lastdata] [varchar] (80) NULL ,
149 [start] [datetime] NULL ,
150 [answer] [datetime] NULL ,
151 [end] [datetime] NULL ,
152 [duration] [int] NULL ,
153 [billsec] [int] NULL ,
154 [disposition] [varchar] (20) NULL ,
155 [amaflags] [varchar] (16) NULL ,
156 [uniqueid] [varchar] (32) NULL
159 Start asterisk in verbose mode, you should see that asterisk
160 logs a connection to the database and will now record every
161 call to the database when it's complete.
168 If you want to go directly to postgresql database, and have the cdr_pgsql.so
169 compiled you can use the following sample setup.
170 On Debian, before compiling asterisk, just install libpqxx-dev.
171 Other distros will likely have a similiar package.
173 Once you have the compile done,
174 copy the sample cdr_pgsql.conf file or create your own.
178 /etc/asterisk/cdr_pgsql.conf
179 ; Sample Asterisk config file for CDR logging to PostgresSQL
188 ;Now create a table in postgresql for your cdrs
190 ;SQL table where CDRs will be inserted
191 ;Copy and paste this into your postgresql prompt.
193 calldate time NOT NULL ,
194 clid varchar (80) NOT NULL ,
195 src varchar (80) NOT NULL ,
196 dst varchar (80) NOT NULL ,
197 dcontext varchar (80) NOT NULL ,
198 channel varchar (80) NOT NULL ,
199 dstchannel varchar (80) NOT NULL ,
200 lastapp varchar (80) NOT NULL ,
201 lastdata varchar (80) NOT NULL ,
202 duration int NOT NULL ,
203 billsec int NOT NULL ,
204 disposition varchar (45) NOT NULL ,
205 amaflags int NOT NULL ,
206 accountcode varchar (20) NOT NULL ,
207 uniqueid varchar (32) NOT NULL ,
208 userfield varchar (255) NOT NULL
215 RADIUS: See doc/radius.txt for more information on cdr_radius