System information

There are many more options for that we can define for SIP friends, such as the caller
ID; adding that information is as simple as adding a callerid column to the table. See
the sip.conf.sample file for more options that can be defined for SIP friends.
Storing Call Detail Records (CDRs)
Call detail records (CDRs) contain information about calls that have passed through
your Asterisk system. They are discussed further in Chapter 24. Storing CDRs is a
popular use of databases in Asterisk, because it makes them easier to manage (for ex-
ample, you can keep track of many Asterisk systems in a single table). Also, by placing
records into a database you open up many possibilities, including building your own
web interface for tracking statistics such as call usage and most-called locations, billing,
or phone company invoice verification.
Setting the systemname for Globally Unique IDs
A CDR consists of a unique identifier and several fields of information about the call
(including the source and destination channel, length of call, last application executed,
and so forth). In a clustered set of Asterisk boxes, it is theoretically possible to have
duplication among unique identifiers, since each Asterisk system considers only itself.
To address this, we can automatically append a system identifier to the front of the
unique IDs by adding an option to /etc/asterisk/asterisk.conf. For each of your boxes,
set an identifier by adding something like:
[options]
systemname=toronto
The best way to store your call detail records is via the cdr_adaptive_odbc module. This
module allows you to choose which columns of data built into Asterisk are stored in
your table, and permits you to add additional columns that you can populate with the
CDR() dialplan function. You can even store different parts of CDR data to different
tables and databases, if that is required.
More information about the standard CDR columns in Asterisk is available in Ta-
ble 24-2. You can define all or any subset of these records in the database, and Asterisk
will work around what is available. You can also add additional columns to store other
data relevant to the calls. For example, if you wanted to implement least cost routing
(LCR), you could add columns for route, per-minute cost, and per-minute rate. Once
you’ve added those columns, they can be populated via the dialplan by using the
CDR() function (e.g., Set(CDR(per_minute_rate)=0.01)).
Storing Call Detail Records (CDRs) | 375