Вы находитесь на странице: 1из 3

=========================================== COMANDOS PARA ACTIVAR CDR ASTERISK EN MYSQL =========================================== ***************************************** Creacin de base de datos y tablas MySQL *****************************************

mysql -u root -p mysql> CREATE DATABASE asteriskcdrdb; mysql> GRANT INSERT ON asteriskcdrdb.* TO asterisk@localhost IDENTIFIED BY 'v4ly d3l.t3l3st4r'; mysql> USE asteriskcdrdb; mysql> 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 '', userfield varchar(255) NOT NULL default '' ); mysql> mysql> mysql> mysql> ALTER ALTER ALTER ALTER TABLE TABLE TABLE TABLE cdr cdr cdr cdr ADD ADD ADD ADD uniqueid VARCHAR(32) NOT NULL default ''; INDEX ( calldate ); INDEX ( dst ); INDEX ( accountcode );

************************************************* Activacion de tabla de paso para importacion del CDR desde sistema de gestion (si no se necesita, no implementar) ************************************************* -- Creacion de tabla clon para importar la data mysql> CREATE TABLE cdr ( id BIGINT NOT NULL default 0, 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 '', userfield varchar(255) NOT NULL default '', PRIMARY KEY (id) ); -- Creacion de trigger que duplica la data hacia la tabla clon DELIMITER @@ DROP TRIGGER asteriskcdrdb.trigger_cdr_clone @@ CREATE TRIGGER asteriskcdrdb.trigger_cdr_clone AFTER INSERT ON asteriskcdrdb.cdr FOR EACH ROW INSERT INTO cdr_clone VALUES (new.id, new.calldate, new.clid, new.src, new.dst, new.dcontext, new.channel, new.dstchannel, new.lastapp, new.lastdata, new.durati on, new.billsec, new.disposition, new.amaflags, new.accountcode, new.userfield) @@ DELIMITER ;

******************************** Configurar Asterisk CDR Mysql ******************************** nano /etc/asterisk/cdr.conf -------------------------------[general] enabled=yes -------------------------------nano /etc/asterisk/cdr_mysql.conf -------------------------------[global] hostname=localhost dbname=asteriskcdrdb table=cdr password=v4lyd3l.t3l3st4r user=asterisk port=3306 ;sock=/tmp/mysql.sock ;userfield=1 nano /etc/asterisk/modules.conf ----------------------------load => cdr_addon_mysql.so ----------------------------********************************** Reiniciando Asterisk ********************************** asterisk -r

CLI> restart when convenient CLI > asterisk -r CLI > cdr mysql status ======================================= FIN! =======================================