aboutsummaryrefslogtreecommitdiffstats
path: root/doc/cdrdriver.txt
blob: 8a7e2e32895577964b8fb47c4354b7bc35341dbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
Call data records can be stored in many different databases or even CSV text.

MSSQL:		Asterisk can currently store CDRs into an MSSQL database in
		two different ways:  cdr_odbc.c or cdr_tds.c
		
		Call Data Records can be stored using unixODBC (which requires
		the FreeTDS package) [cdr_odbc.c] or directly by using just the
		FreeTDS package [cdr_tds.c]  The following provide some
		examples known to get asterisk working with mssql.
		NOTE:  Only choose one db connector.

	ODBC [cdr_odbc.c]:
		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.c

		   make clean &&
		   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
		   [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

		Only install one database connector.  Do not confuse asterisk
		by using both ODBC (cdr_odbc.c) and FreeTDS (cdr_tds.c).
		This command will erase the contents of cdr_tds.conf 

		[ -f /etc/asterisk/cdr_tds.conf ] > /etc/asterisk/cdr_tds.conf

		NOTE:  unixODBC requires the freeTDS package, but asterisk does
		not call freeTDS directly.

		Setup 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

		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] (32)          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 [cdr_tds.c]:
		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.c  

                   make clean &&
                   make update &&
                   make &&
                   make install

                Only install one database connector.  Do not confuse asterisk
                by using both ODBC (cdr_odbc.c) and FreeTDS (cdr_tds.c).
                This command will erase the contents of cdr_odbc.conf

		[ -f /etc/asterisk/cdr_odbc.conf ] > /etc/asterisk/cdr_odbc.conf

                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] (32)          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.


MYSQL:


PGSQL:
        If you want to go directly to postgresql database, and have the cdr_pgsql.so
        compiled you can use the following sample setup.
        On Debian, before compiling asterisk, just install libpqxx-dev.
        Other distros will likely have a similiar package.

        Once you have the compile done,
        copy the sample cdr_pgsql.conf file or create your own.

        Here is a sample:

        /etc/asterisk/cdr_pgsql.conf
          ; Sample Asterisk config file for CDR logging to PostgresSQL
          [global]
          hostname=localhost
          port=5432
          dbname=asterisk
          password=password
          user=postgres
          table=cdr

        ;Now create a table in postgresql for your cdrs

        ;SQL table where CDRs will be inserted
        ;Copy and paste this into your postgresql prompt.
        CREATE TABLE cdr (
                calldate      time               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 (32)          NOT NULL ,
                userfield     varchar (255)         NOT NULL
        );


SQLLITE:


RADIUS:		See doc/radius.txt for more information on cdr_radius