• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to configure Asterisk CDR & CEL Logging with ODBC Connecter on Debian 12

  • 00:37 cat /etc/os-release
  • 00:53 apt install default-mysql-server -y
  • 01:32 mysql
  • 01:37 create database asterisk;
  • 01:47 create user 'asterisk'@'localhost' identified by 'asterisk@123';
  • 02:16 grant all privileges on *.* to 'asterisk'@'localhost';
  • 02:41 flush privileges;
  • 02:51 use asterisk;
  • 03:03 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 '', dcont
  • 03:11 CREATE TABLE cel ( id BIGINT(20) NOT NULL AUTO_INCREMENT, eventtype VARCHAR(30) NOT NULL DEFAULT '', eventtime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', cid_name VARCHAR(80) NOT NULL D
  • 03:26 select * from cdr;
  • 03:36 select * from cel;
  • 03:50 exit
  • 03:53 apt install unixodbc unixodbc-dev -y
  • 04:24 wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-client-plugins_8.3.0-1debian12_amd64.deb
  • 04:36 dpkg -i mysql-community-client-plugins_8.3.0-1debian12_amd64.deb
  • 04:49 wget https://downloads.mysql.com/archives/get/p/10/file/mysql-connector-odbc_8.3.0-1debian12_amd64.deb
  • 04:59 dpkg -i mysql-connector-odbc_8.3.0-1debian12_amd64.deb
  • 05:11 wget https://downloads.mysql.com/archives/get/p/10/file/mysql-connector-odbc-setup_8.3.0-1debian12_amd64.deb
  • 05:23 dpkg -i mysql-connector-odbc-setup_8.3.0-1debian12_amd64.deb
  • 05:37 vim /etc/odbcinst.ini
  • 06:01 vim /etc/odbc.ini
  • 08:51 isql -v asterisk
  • 09:09 vim /etc/asterisk/res_odbc.conf
  • 10:25 vim /etc/asterisk/cdr_odbc.conf
  • 11:37 vim /etc/asterisk/cel_odbc.conf
  • 12:53 asterisk -rvvvvvvvvvvvvvvvvvvvv
  • 13:05 module load res_odbc
  • 13:25 module load res_odbc_transaction
  • 13:45 module load res_odbc
  • 14:04 module load cdr_odbc
  • 14:23 module load cel_odbc
  • 14:39 odbc show
  • 14:54 exit
  • 15:06 vim /etc/asterisk/res_odbc.conf
  • 15:47 asterisk -rvvvvvvvvvvvvvvvvvvvv
  • 16:13 module reload res_odbc
  • 16:37 odbc show
  • 17:21 exit
  • 17:24 mysql
  • 17:31 use asterisk;
  • 17:41 select * from cdr;
7870

To Configure Asterisk CDR & CEL Logging With ODBC Connecter On Debian 12

Introduction:

Asterisk, a highly-effective open-source PBX (Private Branch Exchange) software, offers robust logging capabilities through its Call Detail Records (CDR) and Call Event Logging (CEL) features. These logs contain vital information about calls, allowing administrators to track and analyze call activities for reporting, issue resolution, and billing needs.

Procedure:

Step 1 : Check the OS version by using following command.

root@linuxhelp:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Step 2 : Install the MySQL by using following command.

root@linuxhelp:~# apt install default-mysql-server -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  galera-4 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdaxctl1 libdbd-mariadb-perl libdbi-perl libfcgi-bin
  libfcgi-perl libfcgi0ldbl libhtml-template-perl libmariadb3 libndctl6 libpmem1 libsigsegv2 libterm-readkey-perl liburing2 mariadb-client
  mariadb-client-core mariadb-common mariadb-plugin-provider-bzip2 mariadb-plugin-provider-lz4 mariadb-plugin-provider-lzma
  mariadb-plugin-provider-lzo mariadb-plugin-provider-snappy mariadb-server mariadb-server-core pv rsync socat
Suggested packages:
  gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test netcat-openbsd doc-base
  python3-braceexpand
The following NEW packages will be installed:
  default-mysql-server galera-4 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdaxctl1 libdbd-mariadb-perl libdbi-perl
  libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl libndctl6 libpmem1 libsigsegv2 libterm-readkey-perl liburing2 mariadb-client
  mariadb-client-core mariadb-plugin-provider-bzip2 mariadb-plugin-provider-lz4 mariadb-plugin-provider-lzma mariadb-plugin-provider-lzo
  mariadb-plugin-provider-snappy mariadb-server mariadb-server-core pv rsync socat
The following packages will be upgraded:
  libmariadb3 mariadb-common
2 upgraded, 30 newly installed, 0 to remove and 72 not upgraded.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
Setting up mariadb-plugin-provider-bzip2 (1:10.11.6-0+deb12u1) ...
Setting up mariadb-plugin-provider-lzma (1:10.11.6-0+deb12u1) ...
Setting up mariadb-plugin-provider-lzo (1:10.11.6-0+deb12u1) ...
Setting up mariadb-plugin-provider-lz4 (1:10.11.6-0+deb12u1) ...
Setting up mariadb-plugin-provider-snappy (1:10.11.6-0+deb12u1) ...
Setting up default-mysql-server (1.1.0) ...
Processing triggers for libc-bin (2.36-9+deb12u3) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for mariadb-server (1:10.11.6-0+deb12u1) ...

Step 3 : Login to the MySQL by using following command.

root@linuxhelp:~# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 31
Server version: 10.11.6-MariaDB-0+deb12u1 Debian 12

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Step 4 : Create database by using following command.

MariaDB [(none)]> create database asterisk;
Query OK, 1 row affected (0.000 sec)

Step 5 : Create user by using following command.

MariaDB [(none)]> create user 'asterisk'@'localhost' identified by 'asterisk@123';
Query OK, 0 rows affected (0.001 sec)

Step 6 : Make Grant privileges to the user by using following command.

MariaDB [(none)]> grant all privileges on *.* to 'asterisk'@'localhost';
Query OK, 0 rows affected (0.001 sec)

Step 7 : Refresh the privileges by using following command.

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)

Step 8 : Changed to the Asterisk DB by using following command.

MariaDB [(none)]> use asterisk;
Database changed

Step 9 : Create CDR table by using following command.

MariaDB [asterisk]> 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 ''
    -> );
Query OK, 0 rows affected (0.011 sec)

Step 10 : Create CEL table by using following command.

MariaDB [asterisk]> CREATE TABLE cel (
    ->     id BIGINT(20) NOT NULL AUTO_INCREMENT,
    ->     eventtype VARCHAR(30) NOT NULL DEFAULT '',
    ->     eventtime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
    ->     cid_name VARCHAR(80) NOT NULL DEFAULT '',
    ->     cid_num VARCHAR(80) NOT NULL DEFAULT '',
    ->     cid_ani VARCHAR(80) NOT NULL DEFAULT '',
    ->     cid_rdnis VARCHAR(80) NOT NULL DEFAULT '',
    ->     cid_dnid VARCHAR(80) NOT NULL DEFAULT '',
    ->     exten VARCHAR(80) NOT NULL DEFAULT '',
    ->     context VARCHAR(80) NOT NULL DEFAULT '',
    ->     channel VARCHAR(80) NOT NULL DEFAULT '',
    ->     application VARCHAR(80) NOT NULL DEFAULT '',
    ->     appdata VARCHAR(255) NOT NULL DEFAULT '',
    ->     amaflags INT(11) NOT NULL DEFAULT '0',
    ->     accountcode VARCHAR(20) NOT NULL DEFAULT '',
    ->     uniqueid VARCHAR(150) NOT NULL DEFAULT '',
    ->     linkedid VARCHAR(150) NOT NULL DEFAULT '',
    ->     peer VARCHAR(80) NOT NULL DEFAULT '',
    ->     userdeftype VARCHAR(255) NOT NULL DEFAULT '',
    ->     eventextra VARCHAR(512) NOT NULL DEFAULT '',
    ->     PRIMARY KEY (id),
    ->     KEY cel_idx (eventtime,uniqueid)
    -> );
Query OK, 0 rows affected (0.012 sec)

Step 11 : Check the CDR table data's by using following command.

MariaDB [asterisk]> select * from cdr;
Empty set (0.001 sec)

Step 12 : Check the CEL table data's by using following command.

MariaDB [asterisk]> select * from cel;
Empty set (0.001 sec)

Step 13 : Exit from the MySQL console by using following command.

MariaDB [asterisk]> exit
Bye

Step 14 : Install Unix ODBCby using following command.

root@linuxhelp:~# apt install unixodbc unixodbc-dev -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
unixodbc-dev is already the newest version (2.3.11-2+deb12u1).
The following NEW packages will be installed:
  unixodbc
0 upgraded, 1 newly installed, 0 to remove and 72 not upgraded.
Need to get 28.0 kB of archives.
After this operation, 100 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main amd64 unixodbc amd64 2.3.11-2+deb12u1 [28.0 kB]
Fetched 28.0 kB in 0s (166 kB/s)    
Selecting previously unselected package unixodbc.
(Reading database ... 170258 files and directories currently installed.)
Preparing to unpack .../unixodbc_2.3.11-2+deb12u1_amd64.deb ...
Unpacking unixodbc (2.3.11-2+deb12u1) ...
Setting up unixodbc (2.3.11-2+deb12u1) ...
Processing triggers for man-db (2.11.2-2) ...

Step 15 : Download the MySQL ODBC connector dependency by using following command.

root@linuxhelp:~# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-client-plugins_8.3.0-1debian12_amd64.deb
--2024-06-20 05:37:00--  https://downloads.mysql.com/archives/get/p/23/file/mysql-community-client-plugins_8.3.0-1debian12_amd64.deb
Resolving downloads.mysql.com (downloads.mysql.com)... 23.58.39.183, 2600:140f:9800:191::2e31, 2600:140f:9800:1b8::2e31
Connecting to downloads.mysql.com (downloads.mysql.com)|23.58.39.183|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://cdn.mysql.com/archives/mysql-8.3/mysql-community-client-plugins_8.3.0-1debian12_amd64.deb [following]
--2024-06-20 05:37:01--  https://cdn.mysql.com/archives/mysql-8.3/mysql-community-client-plugins_8.3.0-1debian12_amd64.deb
Resolving cdn.mysql.com (cdn.mysql.com)... 23.58.42.45, 2600:140f:9800:197::1d68, 2600:140f:9800:1b1::1d68
Connecting to cdn.mysql.com (cdn.mysql.com)|23.58.42.45|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2353436 (2.2M) [application/x-debian-package]
Saving to: ‘mysql-community-client-plugins_8.3.0-1debian12_amd64.deb’

mysql-community-client-plugins_8.3 100%[================================================================>]   2.24M  11.1MB/s    in 0.2s    

2024-06-20 05:37:02 (11.1 MB/s) - ‘mysql-community-client-plugins_8.3.0-1debian12_amd64.deb’ saved [2353436/2353436]

Step 16 : Install the MySQL ODBC connector dependency by using following command.

root@linuxhelp:~# dpkg -i mysql-community-client-plugins_8.3.0-1debian12_amd64.deb
Selecting previously unselected package mysql-community-client-plugins.
(Reading database ... 170268 files and directories currently installed.)
Preparing to unpack mysql-community-client-plugins_8.3.0-1debian12_amd64.deb ...
Unpacking mysql-community-client-plugins (8.3.0-1debian12) ...
Setting up mysql-community-client-plugins (8.3.0-1debian12) ...
Processing triggers for libc-bin (2.36-9+deb12u3) ...

Step 17 : Download the MySQL ODBC connector by using following command.

root@linuxhelp:~# wget https://downloads.mysql.com/archives/get/p/10/file/mysql-connector-odbc_8.3.0-1debian12_amd64.deb
--2024-06-20 05:37:28--  https://downloads.mysql.com/archives/get/p/10/file/mysql-connector-odbc_8.3.0-1debian12_amd64.deb
Resolving downloads.mysql.com (downloads.mysql.com)... 23.58.39.183, 2600:140f:9800:191::2e31, 2600:140f:9800:1b8::2e31
Connecting to downloads.mysql.com (downloads.mysql.com)|23.58.39.183|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://cdn.mysql.com/archives/mysql-connector-odbc-8.3/mysql-connector-odbc_8.3.0-1debian12_amd64.deb [following]
--2024-06-20 05:37:29--  https://cdn.mysql.com/archives/mysql-connector-odbc-8.3/mysql-connector-odbc_8.3.0-1debian12_amd64.deb
Resolving cdn.mysql.com (cdn.mysql.com)... 23.58.42.45, 2600:140f:9800:1b1::1d68, 2600:140f:9800:197::1d68
Connecting to cdn.mysql.com (cdn.mysql.com)|23.58.42.45|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1780780 (1.7M) [application/x-debian-package]
Saving to: ‘mysql-connector-odbc_8.3.0-1debian12_amd64.deb’

mysql-connector-odbc_8.3.0-1debian 100%[================================================================>]   1.70M  11.1MB/s    in 0.2s    

2024-06-20 05:37:29 (11.1 MB/s) - ‘mysql-connector-odbc_8.3.0-1debian12_amd64.deb’ saved [1780780/1780780]

Step 18 : Install the MySQL ODBC connector by using following command.

root@linuxhelp:~# dpkg -i mysql-connector-odbc_8.3.0-1debian12_amd64.deb
Selecting previously unselected package mysql-connector-odbc:amd64.
(Reading database ... 170281 files and directories currently installed.)
Preparing to unpack mysql-connector-odbc_8.3.0-1debian12_amd64.deb ...
Unpacking mysql-connector-odbc:amd64 (8.3.0-1debian12) ...
Setting up mysql-connector-odbc:amd64 (8.3.0-1debian12) ...
Registering Unicode driver from in file
Success: Usage count is 1
Registering ANSI driver from in file
Success: Usage count is 1

Step 19 : Download the MySQL ODBC connector setup by using following command.

root@linuxhelp:~# wget https://downloads.mysql.com/archives/get/p/10/file/mysql-connector-odbc-setup_8.3.0-1debian12_amd64.deb
--2024-06-20 05:37:59--  https://downloads.mysql.com/archives/get/p/10/file/mysql-connector-odbc-setup_8.3.0-1debian12_amd64.deb
Resolving downloads.mysql.com (downloads.mysql.com)... 23.58.39.183, 2600:140f:9800:191::2e31, 2600:140f:9800:1b8::2e31
Connecting to downloads.mysql.com (downloads.mysql.com)|23.58.39.183|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://cdn.mysql.com/archives/mysql-connector-odbc-8.3/mysql-connector-odbc-setup_8.3.0-1debian12_amd64.deb [following]
--2024-06-20 05:37:59--  https://cdn.mysql.com/archives/mysql-connector-odbc-8.3/mysql-connector-odbc-setup_8.3.0-1debian12_amd64.deb
Resolving cdn.mysql.com (cdn.mysql.com)... 23.58.42.45, 2600:140f:9800:197::1d68, 2600:140f:9800:1b1::1d68
Connecting to cdn.mysql.com (cdn.mysql.com)|23.58.42.45|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1486428 (1.4M) [application/x-debian-package]
Saving to: ‘mysql-connector-odbc-setup_8.3.0-1debian12_amd64.deb’

mysql-connector-odbc-setup_8.3.0-1 100%[================================================================>]   1.42M  --.-KB/s    in 0.1s    

2024-06-20 05:38:00 (11.1 MB/s) - ‘mysql-connector-odbc-setup_8.3.0-1debian12_amd64.deb’ saved [1486428/1486428]

Step 20 : Install the MySQL ODBC connector setup by using following command.

root@linuxhelp:~# dpkg -i mysql-connector-odbc-setup_8.3.0-1debian12_amd64.deb
Selecting previously unselected package mysql-connector-odbc-setup:amd64.
(Reading database ... 170293 files and directories currently installed.)
Preparing to unpack mysql-connector-odbc-setup_8.3.0-1debian12_amd64.deb ...
Unpacking mysql-connector-odbc-setup:amd64 (8.3.0-1debian12) ...
Setting up mysql-connector-odbc-setup:amd64 (8.3.0-1debian12) ...
Registering Unicode driver using setup package
Success: Usage count is 0
Success: Usage count is 1
Registering ANSI driver using setup
Success: Usage count is 0
Success: Usage count is 1

Step 21 : Check the Driver update in the ODBC inst.ini file by using following command.

root@linuxhelp:~# vim /etc/odbcinst.ini
[MySQL ODBC 8.3 Unicode Driver]
DRIVER=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so
SETUP=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc8S.so
UsageCount=1

[MySQL ODBC 8.3 ANSI Driver]
DRIVER=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so
SETUP=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc8S.so
UsageCount=1

Step 22 : Make the configuration for database connection by using following command.

root@linuxhelp:~# vim /etc/odbc.ini
[asterisk]
Description = MySQL connection to Asterisk CDR database
Driver = MySQL ODBC 8.3 Unicode Driver
Server = localhost
Database = asterisk
User = asterisk
Password = asterisk@123
Port = 3306
Option = 3

Step 23 : Check the ODBC connection by using following command.

root@linuxhelp:~# isql -v asterisk
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| echo [string]                         |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> quit

Step 24 : Configure the Asterisk ODBC connection by using following command.

root@linuxhelp:~# vim /etc/asterisk/res_odbc.conf
[mysql2]
enabled => yes
dsn => asterisk
username => asterisk
password => asterisk@123
pre-connect => yes

Step 25 : Configure the Asterisk CDR oODBC connection by using following command.

root@linuxhelp:~# vim /etc/asterisk/cdr_odbc.conf
[global]
dsn=mysql2
username=asterisk
password=asterisk@123
loguniqueid=yes
table=cdr		;"cdr" is default table name

Step 26 : Configure the Asterisk CEL ODBCconnection by using following command.

root@linuxhelp:~# vim /etc/asterisk/cel_odbc.conf
[general]
connection=mysql2
table=cel
enabled=yes

Step 27 : Login to the Asterisk console by using following command.

root@linuxhelp:~# asterisk -rvvvvvvvvvvvvvvvvvvvv
Asterisk 20.4.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.4.0 currently running on linuxhelp (pid = 965)
linuxhelp*CLI> 

Step 28 : Load the Asterisk ODBC module by using following command.

linuxhelp*CLI> module load res_odbc
Unable to load module res_odbc
Command 'module load res_odbc' failed.
[Jun 20 05:47:22] ERROR[3947]: loader.c:283 module_load_error: res_odbc has one or more unknown dependencies.

Step 29 : Load the Asterisk ODBC dependency module to troubleshoot the error by using following command.

linuxhelp*CLI> module load res_odbc_transaction
Loaded res_odbc_transaction
  == Registered application 'ODBC_Commit'
  == Registered application 'ODBC_Rollback'
  == Registered custom function 'ODBC'
 Loaded res_odbc_transaction.so => (ODBC transaction resource)

Step 30 : Again Load the Asterisk ODBC module by using following command.

linuxhelp*CLI> module load res_odbc
Loaded res_odbc
[Jun 20 05:48:11] NOTICE[3947]: res_odbc.c:697 load_odbc_config: Registered ODBC class 'mysql2' dsn->[asterisk]
 Loaded res_odbc.so => (ODBC resource)

Step 31 : Load the Asterisk CDR ODBC module by using following command.

linuxhelp*CLI> module load cdr_odbc
Loaded cdr_odbc
 Loaded cdr_odbc.so => (ODBC CDR Backend)

Step 32 : Load the Asterisk CEL ODBC module by using following command.

linuxhelp*CLI> module load cel_odbc
Loaded cel_odbc
 Loaded cel_odbc.so => (ODBC CEL backend)

Step 33 : Check the connection of the ODBC by using following command.

linuxhelp*CLI> odbc show

ODBC DSN Settings
-----------------

  Name:   mysql2
  DSN:    asterisk
    Number of active connections: 1 (out of 1)
    Logging: Disabled

Step 34 : Exit from the Asterisk console by using following command.

linuxhelp*CLI> exit
Asterisk cleanly ending (0).
Executing last minute cleanups

Step 35 : Edit the ODBC configuration file to enable the logging by using following command.

root@linuxhelp:~# vim /etc/asterisk/res_odbc.conf
[mysql2]
enabled => yes
dsn => asterisk
username => asterisk
password => asterisk@123
pre-connect => yes
logging => yes

Step 36 : Login to the Asterisk console by using following command.

root@linuxhelp:~# asterisk -rvvvvvvvvvvvvvvvvvvvv
Asterisk 20.4.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.4.0 currently running on linuxhelp (pid = 965)
linuxhelp*CLI> 

Step 37 : Reload the ODBC module by using following command.

linuxhelp*CLI> module reload res_odbc
Module 'res_odbc' reloaded successfully.
	-- Reloading module 'res_odbc.so' (ODBC resource)
[Jun 20 05:55:14] NOTICE[3992]: res_odbc.c:697 load_odbc_config: Registered ODBC class 'mysql2' dsn->[asterisk]

Step 38 : Check the connection of the ODBC by using following command.

linuxhelp*CLI> odbc show

ODBC DSN Settings
-----------------

  Name:   mysql2
  DSN:    asterisk
    Number of active connections: 1 (out of 1)
    Logging: Enabled
    Number of prepares executed: 0
    Number of queries executed: 0

Step 39 : Make the Call to check the CDR and CEL logging by using microsip applications as shown in below image. snap 1

    -- Executing [112@internal:1] Dial("PJSIP/111-00000016", "PJSIP/112") in new stack
    -- Called PJSIP/112
    -- PJSIP/112-00000017 is ringing
       > 0x7f19c001d530 -- Strict RTP learning after remote address set to: 192.168.6.104:4022
    -- PJSIP/112-00000017 answered PJSIP/111-00000016
       > 0x7f19c004ba80 -- Strict RTP learning after remote address set to: 192.168.6.104:4000
    -- Channel PJSIP/112-00000017 joined 'simple_bridge' basic-bridge <3b56634f-f298-41ba-b219-db8dfd24fb68>
    -- Channel PJSIP/111-00000016 joined 'simple_bridge' basic-bridge <3b56634f-f298-41ba-b219-db8dfd24fb68>
       > Bridge 3b56634f-f298-41ba-b219-db8dfd24fb68: switching from simple_bridge technology to native_rtp
       > Locally RTP bridged 'PJSIP/111-00000016' and 'PJSIP/112-00000017' in stack
       > 0x7f19c004ba80 -- Strict RTP switching to RTP target address 192.168.6.104:4000 as source
       > 0x7f19c001d530 -- Strict RTP switching to RTP target address 192.168.6.104:4022 as source
       > Locally RTP bridged 'PJSIP/111-00000016' and 'PJSIP/112-00000017' in stack
       > 0x7f19c004ba80 -- Strict RTP learning complete - Locking on source address 192.168.6.104:4000
       > 0x7f19c001d530 -- Strict RTP learning complete - Locking on source address 192.168.6.104:4022
    -- Channel PJSIP/112-00000017 left 'native_rtp' basic-bridge <3b56634f-f298-41ba-b219-db8dfd24fb68>
    -- Channel PJSIP/111-00000016 left 'native_rtp' basic-bridge <3b56634f-f298-41ba-b219-db8dfd24fb68>
  == Spawn extension (internal, 112, 1) exited non-zero on 'PJSIP/111-00000016'

Step 40 : Exit from the Asterisk console by using following command.

linuxhelp*CLI> exit
Asterisk cleanly ending (0).
Executing last minute clean-ups

Step 41 : Login to the MySQL console by using following command.

root@linuxhelp:~# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 42
Server version: 10.11.6-MariaDB-0+deb12u1 Debian 12

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

Step 42 : Changed to Asterisk DB by using following command.

MariaDB [(none)]> use asterisk;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Step 43 : Check the CDR table by using following command.

MariaDB [asterisk]> select * from cdr;
+---------------------+--------------------+-----+-----+----------+--------------------+--------------------+---------+-----------+----------+---------+-------------+----------+-------------+---------------+-----------+
| calldate            | clid               | src | dst | dcontext | channel            | dstchannel         | lastapp | lastdata  | duration | billsec | disposition | amaflags | accountcode | uniqueid      | userfield |
+---------------------+--------------------+-----+-----+----------+--------------------+--------------------+---------+-----------+----------+---------+-------------+----------+-------------+---------------+-----------+
| 2024-06-20 06:15:08 | "linuxhelp2" <111> | 111 | 110 | internal | PJSIP/111-00000014 | PJSIP/110-00000015 | Dial    | PJSIP/110 |        3 |       1 | 8           |        3 |             | 1718844308.30 |           |
| 2024-06-20 06:16:29 | "linuxhelp2" <111> | 111 | 112 | internal | PJSIP/111-00000016 | PJSIP/112-00000017 | Dial    | PJSIP/112 |       17 |      14 | 8           |        3 |             | 1718844389.33 |           |
+---------------------+--------------------+-----+-----+----------+--------------------+--------------------+---------+-----------+----------+---------+-------------+----------+-------------+---------------+-----------+
2 rows in set (0.001 sec)

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to configure Asterisk CDR and CEL logging with ODBC On Debian 12. Your feedback is much welcome.

Tags:
jacob
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What is the difference between CDR and CEL in Asterisk?

A

CDR (Call Detail Records): Contains detailed information about completed calls, including start time, end time, call duration, caller ID, dialed number, and call quality metrics.
CEL (Call Event Logging): Logs specific events within the call lifecycle, such as call starts, ends, transfers, and application-specific events. CEL provides more granular details compared to CDRs.

Q

Why should I use an ODBC connector for CDR and CEL logging?

A

Using an ODBC connector allows Asterisk to store CDR and CEL data directly into a relational database (e.g., MySQL, PostgreSQL). This approach centralizes logging data, facilitates easier data retrieval, supports scalable storage solutions, and enables integration with third-party reporting and analytics tools.

Q

How do I configure Asterisk to log CDR and CEL data with an ODBC connector?

A

Configuration involves:
Installing the necessary ODBC driver for your chosen database system.
Defining ODBC Data Source Names (DSNs) in odbc.ini or odbcinst.ini.
Editing cdr_odbc.conf for CDR and cel_odbc.conf for CEL to specify the ODBC DSN, database credentials, and logging parameters.
Restarting Asterisk to apply configuration changes and begin logging CDR and CEL data into the database tables.

Q

What are the benefits of using ODBC for CDR and CEL logging?

A

Centralized storage: All CDR and CEL data is stored in a single, reliable database, facilitating easier management and backup.
Scalability: ODBC connectors support databases that can scale to handle large volumes of call data.
Integration: Enables integration with external reporting and analytics tools for comprehensive call analysis and business intelligence.
Customization: Provides flexibility to customize logging parameters and data storage options based on organizational needs.

Q

How can I access and analyze CDR and CEL data stored via ODBC?

A

After configuring ODBC logging, you can use SQL queries directly against the database tables where CDR and CEL data are stored.
Integrate with reporting tools that support SQL queries or have built-in connectors for your database system to generate detailed reports, analytics, and visualizations.
Leverage APIs or scripting to automate data retrieval and analysis processes for real-time monitoring and historical reporting.

Related Tutorials in How to configure Asterisk CDR & CEL Logging with ODBC Connecter on Debian 12

Related Tutorials in How to configure Asterisk CDR & CEL Logging with ODBC Connecter on Debian 12

How to install Gparted on Debian 9.0
How to install Gparted on Debian 9.0
Sep 13, 2017
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Sep 19, 2018
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
Oct 17, 2022
How to install and update OpenSSL on Debian 11.3
How to install and update OpenSSL on Debian 11.3
Oct 21, 2022
How to install qBittorrent on Debian 9.0
How to install qBittorrent on Debian 9.0
Sep 8, 2017
How to Install FileZilla in Debian
How to Install FileZilla in Debian
Nov 29, 2016
How to Install and Configure Mega in Linux
How to Install and Configure Mega in Linux
Jul 19, 2016
How to install Nmap on Debian 9.0
How to install Nmap on Debian 9.0
Sep 9, 2017

Related Forums in How to configure Asterisk CDR & CEL Logging with ODBC Connecter on Debian 12

Related Forums in How to configure Asterisk CDR & CEL Logging with ODBC Connecter on Debian 12

Linux
jayce class=
shasum command not found
May 5, 2017
Linux
stephan class=
How to list all samba users
Jan 12, 2018
pv command
muhammad class=
pvcreate command not found error
May 9, 2017
Linux
henry class=
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
Apr 25, 2017
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Linux
baseer class=
single command to apply setfacl for multiple user at a time
Jan 23, 2018
Linux
beulah class=
What does mean by 0 0 value in fstab file
Jan 2, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018

Related News in How to configure Asterisk CDR & CEL Logging with ODBC Connecter on Debian 12

Related News in How to configure Asterisk CDR & CEL Logging with ODBC Connecter on Debian 12

Anbox, the Android-to-Linux tool the developers have been waiting for
Anbox, the Android-to-Linux tool the developers have been waiting for
Apr 17, 2017
Linus Torvalds stops signing Linux kernel RC tarballs
Linus Torvalds stops signing Linux kernel RC tarballs
May 17, 2017
Capsule8 Launches Linux-Based Container Security Platform
Capsule8 Launches Linux-Based Container Security Platform
Feb 14, 2017
Symantec updates Management console product
Symantec updates Management console product
Nov 22, 2017
Latest Linux driver release feature seven AMD Vega
Latest Linux driver release feature seven AMD Vega
Mar 23, 2017
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
Apr 9, 2019
Microsoft makes its Azure App service now available on Linux Systems
Microsoft makes its Azure App service now available on Linux Systems
Sep 7, 2017
Docker friendly Alpine Linux gets hardened Node.js
Docker friendly Alpine Linux gets hardened Node.js
Apr 19, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Gibbson ?
How do i run both nginx and apache in same instance on centos

Hi...,

my server is based centos operating system and my webserver is already running on Apache.... i need to run both apache and nginx on same instance ... please help me to implement this concept...

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.