System information

After creating your table in the database (which we’ll assume you’ve called cdr), you
need to configure the cdr_adaptive_odbc.conf file in the /etc/asterisk/ folder. The fol-
lowing example will utilize the asterisk connection we’ve defined in res_odbc.conf and
store the data in the cdr table:
; cdr_adaptive_odbc.conf
[adaptive_connection]
connection=asterisk
table=cdr
Yes, really, that’s all you need. After configuring cdr_adaptive_odbc.conf, just reload
the cdr_adaptive_odbc.so module from the Asterisk console by running module reload
cdr_adaptive_odbc.so. You can verify that the Adaptive ODBC backend has been loaded
by running cdr show status:
*CLI> cdr show status
Call Detail Record (CDR) settings
----------------------------------
Logging: Enabled
Mode: Simple
Log unanswered calls: No
* Registered Backends
-------------------
cdr-syslog
Adaptive ODBC
cdr-custom
csv
cdr_manager
Now place a call that gets answered (e.g., using Playback(), or Dial()ing another chan-
nel and answering it). You should get some CDRs stored into your database. You can
check by running SELECT * FROM CDR; from your database console.
With the basic CDR information stored into the database, you might want to add some
additional information to the cdr table, such as the route rate. You can use the ALTER
TABLE directive to add a column called route_rate to the table:
sql> ALTER TABLE cdr ADD COLUMN route_rate varchar(10);
Now reload the cdr_adaptive_odbc.so module from the Asterisk console:
*CLI> module reload cdr_adaptive_odbc.so
and populate the new column from the Asterisk dialplan using the CDR() function,
like so:
exten => _NXXNXXXXXX,1,Verbose(1,Example of adaptive ODBC usage)
same => n,Set(CDR(route_rate)=0.01)
same => n,Dial(SIP/my_itsp/${EXTEN})
same => n,Hangup()
376 | Chapter 16:Relational Database Integration