Cdr Odbc connected but not logging

Running Asterisk 16.5.1

I’m trying to use odbc for cdr logging, but it isn’t working.
It connects but it does not insert into row in database.Any ideia what can it be?
No error in asterisk CLI

PS: Logs and commands result.

 isql asterisk -v
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+

Log when reloading asterisk

[Sep 11 11:08:42] NOTICE[5560]: res_odbc.c:587 load_odbc_config: Adding ENV var: ODBCSYSINI=/etc
[Sep 11 11:08:42] NOTICE[5560]: res_odbc.c:587 load_odbc_config: Adding ENV var: ODBCINI=/ect/odbc.ini
[Sep 11 11:08:43] NOTICE[5560]: res_odbc.c:706 load_odbc_config: Registered ODBC class 'asterisk' dsn->[asterisk]

odbc.ini:

[asterisk]
Description           = MySQL connection to  database
Driver                = MySQL
Database              = asterisk
Server                = localhost
User             = asterisk
Password              = asterisk
Port                  = 3306
Socket                = /var/run/mysqld/mysqld.sock

res_odbc.conf:

[ENV]
ODBCSYSINI => /etc
ODBCINI => /ect/odbc.ini

[asterisk]
enabled => yes
dsn => asterisk
username => asterisk
password => asterisk
max_connections => 1
pre-connect => yes

Those are probably okay ODBC settings, with maybe a need to change password soon.

Do you see Asterisk connecting to your database ?

And can you check your CDR related configuration as well ?

Yes, i’ll change after completing the build, don’t worry :sweat_smile:
And yes, asterisk is connecting to dabase as i can see on Mysql Workbench: Print:
About the CDR related configuration what could i be missing?

[Edit]
I enabled mysql logs and asterisk did not tried to insert data. [Print]

Please check the contents of the files /etc/asterisk/cdr.conf and /etc/asterisk/cdr_odbc.conf

They look alright too:

cdr.conf:

[general]
enable=yes
unanswered = yes

congestion = yes
[csv]
usegmtime=yes
loguniqueid=yes
loguserfield=yes
accountlogs=yes
newcdrcolumns=yes
[mysql]
usegmtime=yes
loguniqueid=yes
loguserfield=yes
accountlogs=yes

and cdr_odbc.conf

[global]
dsn=asterisk
loguniqueid=yes
dispositionstring=yes
table=cdr
usegmtime=no
hrtime=yes

Try changing that to [odbc] in your cdr.conf. Asterisk does not see your MySQL backend directly; it only talks to the ODBC layer, which in turn talks to MySQL.

Probably, this was wrong too, but it still didn’t work.

I don’t think if it helps but i turn CDR log on, and it return log this:

0x7f08c4015750 - Created CDR for channel SIP/7-1-00000143
0x7f08c4015750 - Transitioning CDR for SIP/7-1-00000143 from state NONE to Single
Dial Begin message for SIP/1-00000142, SIP/7-1-00000143: 1568669014.00026161
0x7f08c4005fc0 - Processing Dial Begin message for channel SIP/1-00000142, peer SIP/7-1-00000143
0x7f08c4005fc0 - Updated Party A SIP/1-00000142 snapshot
0x7f08c4005fc0 - Updated Party B SIP/7-1-00000143 snapshot
0x7f08c4005fc0 - Transitioning CDR for SIP/1-00000142 from state Single to Dial
Dial End message for SIP/1-00000142, SIP/7-1-00000143: 1568669014.00077881
0x7f08c4015750 - Set answered time to 1568669017.187680
Dial End message for SIP/1-00000142, SIP/7-1-00000143: 1568669017.00187911
0x7f08c4005fc0 - Processing Dial End message for channel SIP/1-00000142, peer SIP/7-1-00000143
0x7f08c4005fc0 - Transitioning CDR for SIP/1-00000142 from state Dial to DialedPending
0x7f08c4005fc0 - Set answered time to 1568669017.747876
Bridge Enter message for channel SIP/7-1-00000143: 1568669017.00748358
0x7f08c4015750 - Updating Party A SIP/7-1-00000143 snapshot
0x7f08c4015750 - Processing bridge enter for SIP/7-1-00000143
0x7f08c4015750 - Transitioning CDR for SIP/7-1-00000143 from state Single to Bridged
Bridge Enter message for channel SIP/1-00000142: 1568669017.00748455
0x7f08c4005fc0 - Updating Party A SIP/1-00000142 snapshot
0x7f08c4005fc0 - Processing bridge enter for SIP/1-00000142
0x7f08c4005fc0 - Transitioning CDR for SIP/1-00000142 from state DialedPending to Dial
0x7f08c4005fc0 - Transitioning CDR for SIP/1-00000142 from state Dial to Bridged
Bridge Leave message for SIP/7-1-00000143: 1568669020.00065460
0x7f08c4015750 - Processing Bridge Leave for SIP/7-1-00000143
0x7f08c4015750 - Transitioning CDR for SIP/7-1-00000143 from state Bridged to Finalized
Bridge Leave message for SIP/1-00000142: 1568669020.00065521
0x7f08c4005fc0 - Processing Bridge Leave for SIP/1-00000142
0x7f08c4005fc0 - Transitioning CDR for SIP/1-00000142 from state Bridged to Finalized

If it is a connection error asterisk was not supposed to throw an error?

That log looks fine.

Do you have a “cdr” table in your database ?

Do you see CSV records in the /var/log/asterisk/cdr-csv/Master.csv file ?

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