Page 301 - Asterisk™: The Future of Telephony
P. 301

Let’s create a table in our database to store CDR. Log in to the PostgreSQL server with
               the psql application:

                   # psql -U asterisk -h localhost asterisk
                   Password:
               And create the asterisk_cdr table:
                   asterisk=> CREATE TABLE asterisk_cdr
                   (
                     id bigserial NOT NULL,
                     calldate timestamptz,
                     clid varchar(80),
                     src varchar(80),
                     dst varchar(80),
                     dcontext varchar(80),
                     channel varchar(80),
                     dstchannel varchar(80),
                     lastapp varchar(80),
                     lastdata varchar(80),
                     duration int8,
                     billsec int8,
                     disposition varchar(45),
                     amaflags int8,
                     accountcode varchar(20),
                     uniqueid varchar(40),
                     userfield varchar(255),
                     CONSTRAINT asterisk_cdr_id_pk PRIMARY KEY (id)
                   )
                   WITHOUT OIDS;
               You can verify the table was created by using the \dt command (describe tables):

                   asterisk=> \dt asterisk_cdr
                               List of relations
                    Schema |     Name     | Type  |  Owner
                   --------+--------------+-------+----------
                    public | asterisk_cdr | table | asterisk
                   (1 row)
               Next, configure Asterisk to store its CDR into the database. This is done in the /etc/
               asterisk/cdr_odbc.conf file with the following configuration:
                   [global]
                   dsn=asterisk-connector
                   username=asterisk
                   password=welcome
                   loguniqueid=yes
                   table=asterisk_cdr











                                                                   Storing Call Detail Records | 273
   296   297   298   299   300   301   302   303   304   305   306