Link to home
Create AccountLog in
Avatar of AFLLC
AFLLCFlag for United States of America

asked on

asterisk odbc show command is empty and cdr is not working

I'm trying to get odbc working and connected to MySQL for cdr using asterisk 1.8.3.2 and I get no errors and no odbc cdr logging, but it does log to the csv. Can anyone help with this?

I get this output from odbc show:
*CLI> odbc show

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

phreaknasty*CLI>

Open in new window


and this output from cdr show status:
*CLI> cdr show status

Call Detail Record (CDR) settings
----------------------------------
  Logging:                    Enabled
  Mode:                       Simple
  Log unanswered calls:       No

* Registered Backends
  -------------------
    cdr-custom
    csv
    cdr_sqlite3_custom
    Adaptive ODBC

phreaknasty*CLI>

Open in new window


and this output from echo "select 1" | isql -v asterisk-connector:
[root]# echo "select 1" | isql -v asterisk-connector
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> +---------------------+
| 1                   |
+---------------------+
| 1                   |
+---------------------+
SQLRowCount returns 1
1 rows fetched
SQL> [root]#

Open in new window


I have edited these files and restarted asterisk:
/etc/odbcinst.ini
[MySQL]
Description     = ODBC for MySQL
Driver          = /usr/lib/libmyodbc3.so
Setup           = /usr/lib/libodbcmyS.so
FileUsage       = 1

Open in new window


/etc/odbc.ini
[asterisk-connector]
Description             = MySQL connection to 'asterisk' database
Driver                  = MySQL
Database                = asterisk
Server                  = localhost
User                    = asterisk
Password                = ****
Port                    = 3306
Socket                  = /var/lib/mysql/mysql.sock

Open in new window


/etc/asterisk/modules.conf
preload => res_odbc.so
preload => res_config_odbc.so

Open in new window


/etc/asterisk/res_odbc.conf
[asterisk]
enabled => yes
dsn => asterisk-connector
username => asterisk
password => ****
pre-connect => yes
limit => 0
pooling => no

Open in new window


/etc/asterisk/cdr_adaptive_odbc.conf
[first]
connection=asterisk
table=cdr

Open in new window


and I have created a mysql database, user, and table as follows:
CREATE USER 'asterisk'@'localhost' IDENTIFIED BY '****';
CREATE DATABASE asterisk;
GRANT ALL PRIVILEGES ON asterisk.* TO 'asterisk'@'localhost';
FLUSH PRIVILEGES;

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 ''
);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Member_2_1968385
Member_2_1968385
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of AFLLC

ASKER

Thank you, after redoing the setup and following your instructions I found that what was stopping mine from working was the limit => 0 setting that the oreilly book had me put in.