No CDR in cdr MySQL Table

Okay I am struggling to get CDR working. As far as I can tell this is an Asterisk problem and not a FreePBX problem. I have installed from release packages Asterisk 11.25.3 and FreePBX 12.0.76.6 on CentOS 6.10.
Asterisk is putting data in the cel table but not the cdr table.

I found some problems initially with ODBC in that there was no /etc/odbc.ini file, I created it and initially had some incorrect parameters for the socket location. I got that corrected and reinstalled Asterisk.

When I run:

[~]# isql -v MySQL-asteriskcdrdb asteriskuser password
±--------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
±--------------------------------------+
SQL>

So that is working but there is no data in the cdr table.

mysql> select * from cdr;
SQLRowCount returns 0
mysql> select * from cel;
SQLRowCount returns 274

[~]# asterisk -x “odbc show asteriskcdrdb”

ODBC DSN Settings

Name: asteriskcdrdb
DSN: MySQL-asteriskcdrdb
Last connection attempt: 1970-01-01 00:00:00
Pooled: No
Connected: Yes

In the asterisk log after an “apply config” there is:

[2018-08-16 00:53:27] NOTICE[5445] res_odbc.c: Connecting asteriskcdrdb
[2018-08-16 00:53:27] NOTICE[5445] res_odbc.c: res_odbc: Connected to asteriskcdrdb [MySQL-asteriskcdrdb]
[2018-08-16 00:53:27] NOTICE[5445] res_odbc.c: Registered ODBC class ‘asteriskcdrdb’ dsn->[MySQL-asteriskcdrdb]

/etc/asterisk/cdr_mysql.conf settings:

[global]
hostname = localhost
dbname=asteriskcdrdb
password = password
user = asteriskuser
userfield=1
;port=3306
;sock=/tmp/mysql.sock

/etc/asterisk/res_odbc_additional.conf

; Do NOT edit this file as it is auto-generated by FreePBX. ;
[asteriskcdrdb]
enabled=>yes
dsn=>MySQL-asteriskcdrdb
pooling=>no
limit=>1
pre-connect=>yes
username=>asteriskuser
password=> password

So for the life of me I can’t tell why asterisk isn’t putting the cdr records in the database.
Thanks for any help and insight.

Hello maybe these questions could help you:

  • After you have installed your MySQL (mysql and mysql-devel), Did you compile your Asterisk again ?

  • Your cdr_mysql shoud be like this:
    [global]
    hostname=database.host.name
    dbname=asteriskcdrdb
    table=cdr
    password=password
    user=asteriskcdruser
    port=3306
    sock=/tmp/mysql.sock

  • I’m not sure if you omit table field asterisk is going to try to find cdr table by default.

If your problem persists try to create a full log and post here.