Hello
I got a strange issue recently, i setup MySQL as CDR backend, everything is working, but just CDR didn’t insert data to DB
I build Asterisk 18.8 from source code, after flesh installed OS. The cdr_mysql.so is compiled from “make menuselect”, compile was successful,no error.
OS: Ubuntu 20.04
Asterisk: 18.8
in a 4G/40G VM
Mysql is 5.7.36 in docker with phpMyAdmin together.
Everything goes well, except CDR. CDR looks running , but just no data in DB. Even the csv file “Master.csv” is also empty.
my cdr.conf
[general]
enable=yes
unanswered=yes
congestion=yes
debug=true
[csv]
usegmtime=yes ; log date/time in GMT. Default is “no”
loguniqueid=yes ; log uniqueid. Default is "no
loguserfield=yes ; log user field. Default is "no
[mysql]
usegmtime=yes ; log date/time in GMT. Default is “no”
loguniqueid=yes ; log uniqueid. Default is "no
loguserfield=yes ; log user field. Default is "no
[custom]
; We log the unique ID as it can be useful for troubleshooting any issues
; that arise.
loguniqueid=yes
my modules.conf
[modules]
autoload = no
load => app_db.so
load => app_cdr.so
load => app_mysql.so
load => cdr_csv.so
load => cdr_mysql.so
load => func_cdr.so
load => func_db.so
load = cdr_custom.so
…
my cdr_mysql.conf
[global]
hostname=127.0.0.1
dbname=asterisk
table=cdr
password=root
user=root
port=3306
;sock=/tmp/mysql.sock
; By default CDRs are logged in the system’s time zone
;cdrzone=UTC ; log CDRs with UTC
;usegmtime=yes ;log date/time in GMT. Default is “no”
cdrzone=America/Vancouver ; or use a specific time zone
cdr show status
ubuntu*CLI> cdr show status
Call Detail Record (CDR) settings
----------------------------------
Logging: Enabled
Mode: Simple
Log unanswered calls: Yes
Log congestion: Yes
* Registered Backends
-------------------
csv
mysql
cdr_manager
cdr-custom
cdr mysql status
ubuntu*CLI> cdr mysql status
Connected to asterisk@127.0.0.1, port 3306 using table cdr for 8 hours, 35 minutes, 42 seconds
Wrote 0 records since last restart and 0 records since last reconnect.
ubuntu*CLI> module show like mysql
Module Description Use Count Status Support Level
app_mysql.so Simple Mysql Interface 0 Running deprecated
cdr_mysql.so MySQL CDR Backend 0 Running deprecated
res_config_mysql.so MySQL RealTime Configuration Driver 0 Running extended
Asterisk console didn’t report any error.
debug file output (not full, but just cdr_mysql part)
[Dec 6 00:10:00] VERBOSE[1706] loader.c: Unloading cdr_mysql.so
[Dec 6 00:10:00] VERBOSE[1706] cdr.c: Unregistered 'mysql' CDR backend
[Dec 6 00:10:00] DEBUG[1706] loader.c: Unregistering module cdr_mysql
[Dec 6 00:10:05] DEBUG[1706] loader.c: Registering module cdr_mysql
[Dec 6 00:10:05] DEBUG[1706] config.c: Parsing /etc/asterisk/cdr_mysql.conf
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got hostname of 127.0.0.1
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got port of 3306
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a timeout of 0
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got user of root
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got dbname of asterisk
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got password of root
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Not running in calldate compatibility mode
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Dates and times are localized to America/Vancouver
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Successfully connected to MySQL database.
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'id' of type 'int(11) unsigned'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'id'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'id'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'int(11) unsigned'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'calldate' of type 'datetime'
[Dec 6 00:10:05] VERBOSE[1706] cdr_mysql.c: Found alias start for column calldate
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'calldate'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'start'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'datetime'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'clid' of type 'varchar(80)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'clid'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'clid'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(80)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'src' of type 'varchar(80)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'src'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'src'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(80)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'dst' of type 'varchar(80)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'dst'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'dst'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(80)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'dcontext' of type 'varchar(80)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'dcontext'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'dcontext'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(80)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'lastapp' of type 'varchar(200)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'lastapp'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'lastapp'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(200)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'lastdata' of type 'varchar(200)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'lastdata'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'lastdata'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(200)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'duration' of type 'float unsigned'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'duration'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'duration'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'float unsigned'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'billsec' of type 'float unsigned'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'billsec'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'billsec'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'float unsigned'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'disposition' of type 'enum('ANSWERED','BUSY','FAILED','NO ANSWER','CONGESTION')'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'disposition'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'disposition'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'enum('ANSWERED','BUSY','FAILED','NO ANSWER','CONGESTION')'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'channel' of type 'varchar(50)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'channel'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'channel'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(50)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'dstchannel' of type 'varchar(50)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'dstchannel'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'dstchannel'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(50)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'amaflags' of type 'varchar(50)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'amaflags'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'amaflags'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(50)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'accountcode' of type 'varchar(20)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'accountcode'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'accountcode'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(20)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'uniqueid' of type 'varchar(32)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'uniqueid'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'uniqueid'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'varchar(32)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'userfield' of type 'float unsigned'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'userfield'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'userfield'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'float unsigned'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'answer' of type 'datetime'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'answer'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'answer'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'datetime'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Got a field 'end' of type 'datetime'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: Entry name 'end'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: cdrname 'end'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: static '(null)'
[Dec 6 00:10:05] DEBUG[1706] cdr_mysql.c: type 'datetime'
[Dec 6 00:10:05] VERBOSE[1706] loader.c: Loaded cdr_mysql.so => (MySQL CDR Backend)
[Dec 6 00:10:06] DEBUG[871] res_pjsip_registrar.c: Woke up at 1638749406 Interval: 30
[Dec 6 00:10:06] DEBUG[871] res_pjsip_registrar.c: Expiring 0 contacts
[Dec 6 00:10:33] DEBUG[2056] threadpool.c: Worker thread idle timeout reached. Dying.
[Dec 6 00:10:33] DEBUG[2060] threadpool.c: Worker thread idle timeout reached. Dying.
[Dec 6 00:10:33] DEBUG[2051] threadpool.c: Worker thread idle timeout reached. Dying.
[Dec 6 00:10:33] DEBUG[2059] threadpool.c: Worker thread idle timeout reached. Dying.
[Dec 6 00:10:33] DEBUG[2055] threadpool.c: Worker thread idle timeout reached. Dying.
MySQL give root all privilege.
Also, I tested by typing " mysql -h127.0.0.1 -uroot -p" to connect DB, is working
BTW, i created table via this SQL
CREATE TABLE `cdr` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`calldate` DATETIME NOT NULL,
`clid` VARCHAR(80) NOT NULL DEFAULT '',
`src` VARCHAR(80) NOT NULL DEFAULT '',
`dst` VARCHAR(80) NOT NULL DEFAULT '',
`dcontext` VARCHAR(80) NOT NULL DEFAULT '',
`lastapp` VARCHAR(200) NOT NULL DEFAULT '',
`lastdata` VARCHAR(200) NOT NULL DEFAULT '',
`duration` FLOAT UNSIGNED NULL DEFAULT NULL,
`billsec` FLOAT UNSIGNED NULL DEFAULT NULL,
`disposition` ENUM('ANSWERED','BUSY','FAILED','NO ANSWER','CONGESTION') NULL DEFAULT NULL,
`channel` VARCHAR(50) NULL DEFAULT NULL,
`dstchannel` VARCHAR(50) NULL DEFAULT NULL,
`amaflags` VARCHAR(50) NULL DEFAULT NULL,
`accountcode` VARCHAR(20) NULL DEFAULT NULL,
`uniqueid` VARCHAR(32) NOT NULL DEFAULT '',
`userfield` FLOAT UNSIGNED NULL DEFAULT NULL,
`answer` DATETIME NOT NULL,
`end` DATETIME NOT NULL,
PRIMARY KEY (`id`),
INDEX `calldate` (`calldate`),
INDEX `dst` (`dst`),
INDEX `src` (`src`),
INDEX `dcontext` (`dcontext`),
INDEX `clid` (`clid`)
)
COLLATE='utf8_bin'
ENGINE=InnoDB;
when I try dial from A to B , console output is
last loaded. Not taking any action.
-- Added contact 'sip:1102@192.168.1.86:63244;rinstance=05a64e7c13860c28' to AOR '1102' with expiration of 3600 seconds
== Endpoint 1102 is now Reachable
-- Added contact 'sip:1110@192.168.1.64:5060;transport=UDP;rinstance=ca4768739a18196b' to AOR '1110' with expiration of 70 seconds
== Endpoint 1110 is now Reachable
-- Removed contact 'sip:1110@192.168.1.64:5060;transport=UDP;rinstance=ca4768739a18196b' from AOR '1110' due to request
== Contact 1110/sip:1110@192.168.1.64:5060;transport=UDP;rinstance=ca4768739a18196b has been deleted
== Endpoint 1110 is now Unreachable
-- Added contact 'sip:1110@192.168.1.64:5060;transport=UDP;rinstance=36ed1be38a5c2ec5' to AOR '1110' with expiration of 60 seconds
== Endpoint 1110 is now Reachable
0x7fc5d8000e90 - Created CDR for channel PJSIP/1102-00000000
0x7fc5d8000e90 - Transitioning CDR for PJSIP/1102-00000000 from state NONE to Single
-- Executing [1110@Long-Distance:1] NoOp("PJSIP/1102-00000000", "") in new stack
-- Executing [1110@Long-Distance:2] Set("PJSIP/1102-00000000", "CDR_PROP(disable)=1") in new stack
-- Executing [1110@Long-Distance:3] Goto("PJSIP/1102-00000000", "Internal-Main,1110,1") in new stack
-- Goto (Internal-Main,1110,1)
-- Executing [1110@Internal-Main:1] Verbose("PJSIP/1102-00000000", "1, "User 1102 dialed 1110."") in new stack
"User 1102 dialed 1110."
-- Executing [1110@Internal-Main:2] Set("PJSIP/1102-00000000", "SAC_DIALED_EXTEN=1110") in new stack
-- Executing [1110@Internal-Main:3] GotoIf("PJSIP/1102-00000000", "0?dialed-BUSY,1:") in new stack
-- Executing [1110@Internal-Main:4] Dial("PJSIP/1102-00000000", "PJSIP/1110,30") in new stack
-- Called PJSIP/1110
0x7fc5d8001570 - Created CDR for channel PJSIP/1110-00000001
0x7fc5d8001570 - Transitioning CDR for PJSIP/1110-00000001 from state NONE to Single
Dial Begin message for PJSIP/1102-00000000, PJSIP/1110-00000001: 1638810767.00311170
0x7fc5d8000e90 - Processing Dial Begin message for channel PJSIP/1102-00000000, peer PJSIP/1110-00000001
0x7fc5d8000e90 - Updated Party A PJSIP/1102-00000000 snapshot
0x7fc5d8000e90 - Updated Party B PJSIP/1110-00000001 snapshot
0x7fc5d8000e90 - Transitioning CDR for PJSIP/1102-00000000 from state Single to Dial
-- PJSIP/1110-00000001 is ringing
Dial End message for PJSIP/1102-00000000, PJSIP/1110-00000001: 1638810767.00710208
-- PJSIP/1110-00000001 answered PJSIP/1102-00000000
0x7fc5d8001570 - Set answered time to 1638810773.457603
Dial End message for PJSIP/1102-00000000, PJSIP/1110-00000001: 1638810773.00457684
0x7fc5d8000e90 - Processing Dial End message for channel PJSIP/1102-00000000, peer PJSIP/1110-00000001
0x7fc5d8000e90 - Transitioning CDR for PJSIP/1102-00000000 from state Dial to DialedPending
0x7fc5d8000e90 - Set answered time to 1638810773.457824
-- Channel PJSIP/1110-00000001 joined 'simple_bridge' basic-bridge <12533b67-bc9f-4bf1-a487-5b112c4cf626>
Bridge Enter message for channel PJSIP/1110-00000001: 1638810773.00465907
0x7fc5d8001570 - Updating Party A PJSIP/1110-00000001 snapshot
0x7fc5d8001570 - Processing bridge enter for PJSIP/1110-00000001
0x7fc5d8001570 - Transitioning CDR for PJSIP/1110-00000001 from state Single to Bridged
-- Channel PJSIP/1102-00000000 joined 'simple_bridge' basic-bridge <12533b67-bc9f-4bf1-a487-5b112c4cf626>
Bridge Enter message for channel PJSIP/1102-00000000: 1638810773.00466405
0x7fc5d8000e90 - Updating Party A PJSIP/1102-00000000 snapshot
0x7fc5d8000e90 - Processing bridge enter for PJSIP/1102-00000000
0x7fc5d8000e90 - Transitioning CDR for PJSIP/1102-00000000 from state DialedPending to Dial
0x7fc5d8000e90 - Transitioning CDR for PJSIP/1102-00000000 from state Dial to Bridged
-- Started music on hold, class 'default', on channel 'PJSIP/1110-00000001'
-- Channel PJSIP/1102-00000000 left 'simple_bridge' basic-bridge <12533b67-bc9f-4bf1-a487-5b112c4cf626>
-- Channel PJSIP/1110-00000001 left 'simple_bridge' basic-bridge <12533b67-bc9f-4bf1-a487-5b112c4cf626>
== Spawn extension (Internal-Main, 1110, 4) exited non-zero on 'PJSIP/1102-00000000'
Bridge Leave message for PJSIP/1102-00000000: 1638810815.00348203
0x7fc5d8000e90 - Processing Bridge Leave for PJSIP/1102-00000000
0x7fc5d8000e90 - Transitioning CDR for PJSIP/1102-00000000 from state Bridged to Finalized
Bridge Leave message for PJSIP/1110-00000001: 1638810815.00348251
0x7fc5d8001570 - Processing Bridge Leave for PJSIP/1110-00000001
0x7fc5d8001570 - Transitioning CDR for PJSIP/1110-00000001 from state Bridged to Finalized
-- Stopped music on hold on PJSIP/1110-00000001
-- Executing [h@Internal-Main:1] Hangup("PJSIP/1102-00000000", "") in new stack
== Spawn extension (Internal-Main, h, 1) exited non-zero on 'PJSIP/1102-00000000'
0x7fc5d8000e90 - Beginning finalize/dispatch for PJSIP/1102-00000000
0x7fc5d8000e90 - Dispatching CDR for Party A PJSIP/1102-00000000, Party B PJSIP/1110-00000001
0x7fc5d8001570 - Beginning finalize/dispatch for PJSIP/1110-00000001
0x7fc5d8001570 - Dispatching CDR for Party A PJSIP/1110-00000001, Party B <none>
Any idea, where is wrong ?
Also, how to use res_conf_mysql.so ? i saw many posts metioned that it could connect to MySQL via ODBC. Why not directly connect to MySQL ? and res_conf_mysql.so was called “MySQL RealTime Configuration Driver”, Does that mean cdr_mysql.so is not realtime? so even I have make phone call from A to B , but CDR engine didn’t send to DB until some signal received(not realtime) ?
Thanks