[MySQL CDR] - Insert the asterisk without calldate field

Dear,

I’m running Asterisk version 11.5.1 using MySQL version 5.1.69-log for recording the tickets. The distro I’m using is CentOS 6.4 32-bit version with kernel version 2.6.32-358.18.1.el6.i686.
What I want is to write tickets in the bank, this is occurring, but the field has been zeroed calldate. 've Identified why, in fact when the asterisk does not insert field calldate comes as standard and the bank is put '0000-00-00 00:00:00 '.

Command that runs asterisk: INSERT INTO dr (clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,uniqueid)

So if you wanted to know how to fix it, as did dozens of search and did not find where to make this correction.

thank you

Ivan Paes

Which module is used to post the CDR (cdr_mysql.so or cdr_adaptive_odbc.so or cdr_odbc.so) ?
Pls show the output of asterisk- rx “cdr show status”.
And pls post the content of the appropriate conf-file (cdr_mysql.conf, cdr_odbc.conf or cdr_adaptive_odbc.conf).

At least it would be helpful to see Your mysql-tablestructure (desc cdr within mysql).

I think Your problem is a missing mapping but to be sure we need to look at Your conf-Files and Your database-table first

Hello abw10im ,

First thanks for your help . I will try to answer your questions :

Which module is used to post the CDR ( or cdr_mysql.so cdr_adaptive_odbc.so or cdr_odbc.so ) ?
I can not answer that question, but I believe it is the cdr_adaptive_odbc.so as those you mentioned only set up the file cdr_adaptive_odbc.conf .

Pls show the output of asterisk- rx " cdr show status " .
[root @ localhost ~ ] # asterisk- rx " cdr show status "

Call Detail Record ( CDR ) settings

Logging : Enabled
Mode: Simple
Log unanswered calls : No
Log congestion : No

  • Registered Backends

    csv
    Adaptive ODBC
    cdr -custom

[root @ localhost ~ ] #

And pls post the content of the Appropriate conf -file ( cdr_mysql.conf , cdr_odbc.conf or cdr_adaptive_odbc.conf ) .
File cdr_odbc.conf :

;
, cdr_odbc.conf
;

, [ global]
, dsn = MySQL -test
, loguniqueid = yes
, dispositionstring = yes
, table = cdr ; " cdr " is default table name
, usegmtime = no , set to " yes " to log in GMT
, hrtime = yes ; Enables microsecond accuracy with the billsec and duration fields

File cdr_adaptive_odbc.conf :

[ adaptive_connection ]
connection = asterisk
table = cdr

File cdr_mysql.conf :

;
, Note - if the database server is hosted on the machine the same- the
, Asterisk server , you can Achieve a local Unix socket connection by
, Setting hostname = localhost
;
, Port and sock Both are optional parameters . If hostname is specified
, And is not " localhost " (you can use address 127.0.0.1 instead ) , then
, Cdr_mysql will attempt to connect to the specified port or use the
Being the default port . If hostname is not specified or if hostname is
, " Localhost " , then cdr_mysql will attempt to connect to the socket file
, Specified by sock or otherwise use the default socket file .
;
, [ global]
, hostname = database.host.name
, dbname = asteriskcdrdb
, table = cdr
, password = password
, user = asteriskcdruser
, port = 3306
, sock = / tmp / mysql.sock
, timezone = UTC ; Previously called usegmtime
;
, If your system 's locale Differs from mysql database character set ,
, Cdr_mysql can damage non - latin characters in CDR variables. Use this
, Option to protect your data .
; charset = koi8r
;
, Older versions of cdr_mysql Set the field to calldate Whenever the
, Record was posted , rather than the start date of the call . this flag
, Reverts to the old ( incorrect) behavior. Note that you’ll also need
, To comment out the " start = calldate " alias , below , to use this .
, compat = no
;
, Ssl connections (optional )
, ssl_ca =
, ssl_cert =
, ssl_key =
;
, You may also configure the field names used in the CDR table .
;
[ columns ]
; static " " = >
, alias = >
alias start = > calldate
, alias clid = > <a_field_not_named_clid>
, alias src = > <a_field_not_named_src>
, alias dst = > <a_field_not_named_dst>
, alias dcontext = > <a_field_not_named_dcontext>
, alias channel = > <a_field_not_named_channel>
, alias dstchannel = > <a_field_not_named_dstchannel>
, alias lastapp = > <a_field_not_named_lastapp>
, alias lastdata = > <a_field_not_named_lastdata>
, alias duration = > <a_field_not_named_duration>
, alias billsec = > <a_field_not_named_billsec>
, alias disposition = > <a_field_not_named_disposition>
, alias amaflags = > <a_field_not_named_amaflags>
, alias accountcode = > <a_field_not_named_accountcode>
, alias UserField = > <a_field_not_named_userfield>
, alias uniqueid = > <a_field_not_named_uniqueid>

At least it would be helpful to see Your mysql - tablestructure ( cdr desc Within mysql ) .

This I did not understand , but I imagine it would be like the table was created , then follows the script used :

CREATE TABLE cdr (
calldate datetime NOT NULL default ‘0000 - 00-00 00:00:00 ’ ,
clid varchar ( 80 ) NOT NULL default’’ ,
src varchar ( 80 ) NOT NULL default’’ ,
dst varchar ( 80 ) NOT NULL default’’ ,
dcontext varchar ( 80 ) NOT NULL default’’ ,
channel varchar ( 80 ) NOT NULL default’’ ,
dstchannel varchar ( 80 ) NOT NULL default’’ ,
lastapp varchar ( 80 ) NOT NULL default’’ ,
lastdata varchar ( 80 ) NOT NULL default’’ ,
duration int ( 11 ) NOT NULL default ‘0 ’ ,
billsec int ( 11 ) NOT NULL default ‘0 ’ ,
disposition varchar ( 45 ) NOT NULL default’’ ,
amaflags int ( 11 ) NOT NULL default ‘0 ’ ,
accountcode varchar ( 20 ) NOT NULL default’’ ,
uniqueid varchar ( 32 ) NOT NULL default’’ ,
UserField varchar ( 255 ) NOT NULL default’’
);

I hope you managed to pass the information you need.

thank you

Ivan Paes

Ok, You’re using cdr_adaptive_odbc.so.
The reason for Your problem is a mssing configuration parameter in cdr_adaptive_odbc.conf.
Just change the conf-File to the following content for section [ adaptive_connection ]

[ adaptive_connection ] connection = asterisk table = cdr alias start => calldate

Afterwards issue an asterisk -rx “module reload cdr_adaptive_odbc.so”

and You should see that the column calldate gets filled (for new calls :smiley: ).

Hello abw1oim,

Made the setting as you indicated and now the field calldate is correct. Perfect!

Command asterisk.

Information on the Bank.

NOTE: The server date is wrong!

Thank you for your help.

Ivan Paes

Perfect ! This helped me as well! Thank you.

alias start => calldate