CDR backend problem (unable to connect to the database)

Hi,

I’m having a problem with the CDRs not being written into the database lately. They have never worked, but I think I’m rather close to fix this. I was hoping someone can help understanding what the problem is. I’m running Asterisk 16 and FreePBX 15 on Debian.

I can connect to database with mysql and the below configured user fine. I cannot somehow make connection between asterisk and database and I get this error

– Reloading module ‘res_odbc.so’ (ODBC resource)
[2019-01-22 16:20:24] WARNING[7978]: res_odbc.c:941 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified
[2019-01-22 16:20:24] NOTICE[7978]: res_odbc.c:596 load_odbc_config: Registered ODBC class ‘asteriskcdrdb’ dsn->[MySQL-asteriskcdrdb]
[2019-01-22 16:20:24] NOTICE[7978]: res_odbc.c:488 load_odbc_config: Adding ENV var: ODBCSYSINI=/etc
[2019-01-22 16:20:24] NOTICE[7978]: res_odbc.c:488 load_odbc_config: Adding ENV var: ODBCINI=/etc/odbc.ini
– Reloading module ‘extconfig’ (Configuration)
– Reloading module ‘res_config_odbc.so’ (Realtime ODBC configuration)
– Reloading module ‘cdr’ (CDR Engine)
[2019-01-22 16:20:24] NOTICE[7978]: cdr.c:4485 cdr_toggle_runtime_options: CDR simple logging enabled.
– Reloading module ‘cdr_adaptive_odbc.so’ (Adaptive ODBC CDR backend)
[2019-01-22 16:20:24] WARNING[7978]: res_odbc.c:941 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified
[2019-01-22 16:20:24] WARNING[7978]: cdr_adaptive_odbc.c:136 load_config: No such connection ‘asteriskcdrdb’ in the ‘asteriskcdrdb’ section of cdr_adaptive_odbc.conf. Check res_odbc.conf.

<odbc.ini>
[asteriskcdrdb]
Description=MySQL connection to ‘asteriskcdrdb’ database
#driver=MySQL
driver=/usr/lib/x86_64-linux-gnu/libmysqlclient.so
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/run/mysqld/mysql.sock
option=3
Charset=utf8
Trace=Yes
username=cdruser
password=password

<odbcinst.ini>
[MySQL]
Description = ODBC for MySQL
Driver64 = /usr/lib/x86_64-linux-gnu/libodbc.so
Setup64 = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
#Driver64 = /usr/lib64/libmyodbc5.so
#Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1
Pooling = Yes
CPTimeout = 120

<res_odbc.conf>
#include res_odbc_custom.conf
#include res_odbc_additional.conf
[ENV]
ODBCSYSINI => /etc
ODBCINI => /etc/odbc.ini

<res_odbc_additional.conf>
[asteriskcdrdb]
enabled=>yes
dsn=>MySQL-asteriskcdrdb
pre-connect=>yes
max_connections=>5
username=>cdruser
password=>password
database=>asteriskcdrdb

Now I think that error tries to tell me I don’t have Data Source configured in the odbc.ini, but I don’t know how to configure it. I’ve found this somewhere else, but I’m struggling to see what should I use for Asterisk

[ODBC Data Sources]
MapR Drill 32-bit=MapR Drill ODBC Driver 32-bit
MapR Drill 64-bit=MapR Drill ODBC Driver 64-bit

Secondly, even isql is giving me error.

isql -v asteriskcdrdb cdruser password
[IM004][unixODBC][Driver Manager]Driver’s SQLAllocHandle on SQL_HANDLE_HENV failed
[ISQL]ERROR: Could not SQLConnect

Does anyone please know how to configure Data Source in odbc configuration and how can I perhaps make changes to the configuration in FreePBX GUI (as I cannot make changes to the res_odbc.conf in shell) so I can proceed? I’m out of ideas.

Thank you,
Kind regards,

You have no DSN for MYSQL-asteriskcdrdb just asteriskcdrdb

Hi Tom, just to make sure I’m on the same page. Shall I then change every occurrence of ‘MySQL-asteriskcdrdb’ to ‘asteriskcdrdb’

#Edit: I tried changing the values to asteriskcdrdb but I could still see this in asterisk console

ODBC DSN Settings

Name: asteriskcdrdb
DSN: MySQL-asteriskcdrdb
Last fail connection attempt: 2019-01-22 17:38:43
Number of active connections: 0 (out of 5)

The configuration of res_odbc_additional.conf changes itself after reboot back to MySQL-asteriskcdrdb

Thanks,

My CDR manager is running, I’m still not sure what is the problem.
module load cdr_manager
Unable to load module cdr_manager
Command ‘module load cdr_manager’ failed.
[2019-01-24 21:48:09] WARNING[4328]: loader.c:1631 load_resource: Module ‘cdr_manager’ already loaded and running.

And, I was fixing until I broke it. I can’t use fwconsole anymore (reload, status, restart won’t work)
Whoops\Exception\ErrorException: Methods with the same name as their class will not be constructors in a future version of PHP; gui_link_nw_tab has a deprecated constructor in file /var/www/html/admin/modules/endpointman/functions.inc.php on line 284
Stack trace:
_ 1. Whoops\Exception\ErrorException->() /var/www/html/admin/modules/endpointman/functions.inc.php:284_
_ 2. Whoops\Run->handleError() /var/www/html/admin/bootstrap.php:364_
_ 3. require_once() /var/www/html/admin/bootstrap.php:364_
_ 4. require_once() /etc/freepbx.conf:9_
_ 5. include_once() /var/lib/asterisk/bin/fwconsole:12_

Okay, just found out it’s a known issue https://issues.freepbx.org/browse/FC-269.

Is there any entry in FreePBX for CDR settings? Is it supposed to be changed via shell?

Thanks,

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.