Asterisk 1.8. CDR в MySQL. (cdr_adaptive_odbc)

Для того, чтобы сабж заработал необходимо поставить
aptitude install unixodbc-dev libmyodbc

затем собрать астера включив



Конфиги:
/etc/asterisk/res_odbc.conf

[asterisk]
enabled => yes
dsn => MySQL-asterisk
username => asterisk_user
password => 232d2edxse3e


cdr_adaptive_odbc.conf

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


/etc/odbc.ini
[MySQL-asterisk]
Description = MySQL Asterisk database
;Trace = Off
;TraceFile = stderr
Driver = MySQL
Server = localhost
User = asterisk_user
Password = 232d2edxse3e
;Port = 3306
Socket = /var/run/mysqld/mysqld.sock
Database = asterisk


/etc/odbcinst.ini
[MySQL]
Description = MySQL driver
Driver = /usr/lib/odbc/libmyodbc.so
Setup = /usr/lib/odbc/libodbcmyS.so
CPTimeout =
CPReuse =

*для x64
[MySQL]
Description = MySQL driver
Driver = /usr/lib/i386-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/i386-linux-gnu/odbc/libodbcmyS.so 
CPTimeout =
CPReuse =


Идем в мускул, создадим базу
mysql> create database asterisk;
mysql> use asterisk;
mysql> CREATE TABLE `cdr` (   `id` int(9) unsigned NOT NULL auto_increment,   `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 '',   PRIMARY KEY  (`id`),   KEY `calldate` (`calldate`),   KEY `accountcode` (`accountcode`),   KEY `uniqueid` (`uniqueid`),   KEY `dst` (`dst`),   KEY `src` (`src`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
mysql> grant all on asterisk.* to 'asterisk_user'@'localhost' identified by '232d2edxse3e';
mysql> \q
Bye


Рестартнем астера, проверим
*CLI> odbc show asterisk 

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

  Name:   asterisk
  DSN:    MySQL-asterisk
    Last connection attempt: 1970-01-01 07:00:00
  Pooled: No
  Connected: Yes


позвоним и смотрим
# mysql -e "select * from cdr;" -u root -p asterisk
Enter password: 
+----+---------------------+-----------------------------+-------+------+-----------+--------------------+--------------------+---------+--------------+----------+---------+-------------+----------+-------------+--------------+-----------+
| id | calldate            | clid                        | src   | dst  | dcontext  | channel            | dstchannel         | lastapp | lastdata     | duration | billsec | disposition | amaflags | accountcode | uniqueid     | userfield |
+----+---------------------+-----------------------------+-------+------+-----------+--------------------+--------------------+---------+--------------+----------+---------+-------------+----------+-------------+--------------+-----------+
|  1 | 2012-09-10 12:54:57 | "Romanenko Eugene" <user1> | user1 | 117  | employees | SIP/user1-00000000 | SIP/gsm1-00000001  | Dial    | SIP/gsm1/117 |       21 |      19 | ANSWERED    |        3 |             | 1347256497.0 |           |
|  2 | 2012-09-10 13:11:07 |                             |       | 8255 | incoming  | SIP/gsm1-00000002  | SIP/user1-00000003 | Dial    | SIP/user1,,m |       41 |      37 | ANSWERED    |        3 |             | 1347257467.2 |           |
+----+---------------------+-----------------------------+-------+------+-----------+--------------------+--------------------+---------+--------------+----------+---------+-------------+----------+-------------+--------------+-----------+


Все пишется =)

0 комментариев

Только зарегистрированные и авторизованные пользователи могут оставлять комментарии.