text stringlengths 0 152 |
|---|
about it, older versions of this book discuss it in more detail. |
Dynamic Realtime |
The Dynamic Realtime system is used to load objects that may change often, such as |
PJSIP entities, queues and their members, and voicemail. Likewise, when new records |
are likely to be added on a regular basis, we can utilize the power of the database to let |
us load this information on an as-needed basis. |
You have already worked extensively with Dynamic Realtime, since that is how we’ve |
been working for this entire book, both during installation, and in most of the exam‐ |
ples we have worked through. |
All of realtime is configured in the /etc/asterisk/extconfig.conf file; however, Dynamic |
Realtime has explicitly defined configuration names. All the predefined names should |
be configured under the [settings] header. For example, defining SIP peers is done |
using the following format: |
; extconfig.conf |
[settings] |
sippeers => driver,database[,table] |
The table name is optional. If it is omitted, Asterisk will use the predefined name (i.e., |
sippeers) to identify the table in which to look up the data. |
The sample file ~/src/asterisk-15.<TAB>/configs/samples/extconfig.conf.sample con‐ |
tains excellent information about Dynamic Realtime. |
Storing Call Detail Records |
Call detail records (CDR) contain information about calls that have passed through |
your Asterisk system. They are discussed further in Chapter 21. Storing CDR is a |
popular use of databases in Asterisk, because it makes them easier to work with. Also, |
Storing Call Detail Records |
| |
281 |
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 loca‐ |
tions, billing, or phone company invoice verification. |
You should always implement CDR storage to a database on any production system |
(you can always store CDR to a file as well, so there’s nothing lost). |
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 exe‐ |
cuted, 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 it permits you to add additional columns that can be popu‐ |
lated with the CDR() dialplan function. You can even store different parts of CDR data |
to different tables and databases, if that is required. |
To create the table, we have Alembic. The process is almost identical to the one you |
performed during the system installation, except of course the .ini file is different. |
$ cd ~/src/asterisk-15.<TAB>/contrib/ast-db-manage |
$ cp cdr.ini.sample cdr.ini |
$ egrep ^sqlalchemy config.ini |
sqlalchemy.url = mysql://asterisk:YouNeedAReallyGoodPasswordHereToo@localhost/asterisk |
The same credentials we used before will also work for CDR. |
$ sudo vim cdr.ini |
Add the line you just got back from grep to this file, and save. |
$ alembic -c ./cdr.ini upgrade head |
INFO [alembic.runtime.setup] Creating new alembic_version_cdr table. |
INFO [alembic.runtime.migration] Running upgrade -> 210693f3123d, Create CDR table. |
INFO [alembic.runtime.migration] Running upgrade 210693f3123d -> 54cde9847798 |
Alembic doesn’t do too much bragging, so the output is terse, but it appears to have |
completed successfully. Let’s check. |
282 |
| |
Chapter 15: Relational Database Integration |
$ mysql -u asterisk -p |
MySQL> describe asterisk.cdr |
You should get a list of all the fields in the table (which means Alembic was success‐ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.