CDR postgres Asterisk

Par Sylvain Boily - 4/01/2008

Voici une contribution de Damien Griessinger sur l’installation des CDR dans Postgres. Merci à lui !

Installation de postgresql 8.2

vim /etc/apt/sources.list

ajoute cette ligne :

 
deb http://www.backports.org/debian etch-backports main contrib non-free

Puis

wget –O – http://backports.org/debian/archive.key | apt-key add - apt-get update
apt-get install postgresql-8.2
vim /etc/postgresql/8.2/main/postgresql.conf

Dans le fichier :

listen = ‘*’
max_connection = 20 # depend du nombre d’user en simultanés, mais 20 c bon
ssl = false

Puis édition du fichier pg_hba.conf.

vim /etc/postgresql/8.2/main/pg_hba.conf

On autorise les ip, exemple :

host      all         all         192.168.1.196/32          trust    # machine d’admin sans auth

On redémarre Postgres.

/etc/init.d/postgresql-8.2 restart

Puis on crée notre utilisateur postgres.

su - postgres
pgql> createuser –A –D –P xivouser
Mdp : azerty
Confirm : azerty
Can create role (Y/n) :  n

createdb —encoding=latin9 —owner=xivouser xivo

Puis on crée notre base avec le schéma

psql –U xivouser xivo

CREATE TABLE cdr ( acctid bigserial NOT NULL, calldate timestamp with time zone NOT NULL DEFAULT now(), clid character varying(80) NOT NULL DEFAULT ’’ ::character varying, src character varying(80) NOT NULL DEFAULT ’’ ::character varying, dst character varying(80) NOT NULL DEFAULT ’’ ::character varying, dcontext character varying(80) NOT NULL DEFAULT ’’ ::character varying, channel character varying(80) NOT NULL DEFAULT ’’ ::character varying, dstchannel character varying(80) NOT NULL DEFAULT ’’ ::character varying, lastapp character varying(80) NOT NULL DEFAULT ’’ ::character varying, lastdata character varying(80) NOT NULL DEFAULT ’’ ::character varying, duration integer NOT NULL DEFAULT 0, billsec integer NOT NULL DEFAULT 0, disposition character varying(45) NOT NULL DEFAULT ’’ ::character varying, amaflags integer NOT NULL DEFAULT 0, accountcode character varying(20) NOT NULL DEFAULT ’’ ::character varying, uniqueid character varying(32) NOT NULL DEFAULT ’’ ::character varying, userfield character varying(255) NOT NULL DEFAULT ’’ ::character varying, CONSTRAINT cdr_pkey PRIMARY KEY (acctid) ) WITH (OIDS=FALSE) ; ALTER TABLE cdr OWNER TO xivouser ; GRANT ALL ON TABLE cdr TO xivouser ; CREATE INDEX accountcode_ind ON cdr USING btree (accountcode) ;

CREATE INDEX calldate_ind ON cdr USING btree (calldate) ;

CREATE INDEX dst_ind ON cdr USING btree (dst) ;

exit

Connexion de asterisk sur pg

On édite le fichier de configuration

vim /etc/asterisk/cdr_pgsql.conf

[global] hostname=localhost port=5432 dbname=xivo user=xivouser password=azerty table=cdr

Puis on édite le fichier de configuration des CDR.

vim /etc/asterisk/cdr.conf

[general] enable=yes

On édite le fichier des modules d’Asterisk pour activer le cdr_pgsql.

vim /etc/asterisk/modules.conf

Changer le noload

Load => cdr_pgsql.so

Puis on redémarre Asterisk.

/etc/init.d/asterisk restart

Outil web pour les stats

cd /usr/share/pf-xivo-web-interface/www/
wget http://www.areski.net/asterisk-stat...
tar xfvz asterisk-stat-v2_0_1.tar.gz
rm asterisk-stat-v2_0_1.tar.gz
mv asterisk-stat-v2_0_1 stats
cd stats/lib/

vim defines.php

define ("WEBROOT", "https://192.168.1.3/stats/") ; define ("FSROOT", "/usr/share/pf-xivo-web-interface/www/stats/") ; define ("LIBDIR", FSROOT."lib/") ; define ("HOST", "localhost") ; define ("PORT", "5432") ; define ("USER", "xivouser") ; define ("PASS", "azerty") ; define ("DBNAME", "xivo") ; define ("DB_TYPE", "postgres") ; define ("DB_TABLENAME", "cdr") ;

cd .. vim index.php

<?php
 header
('location:cdr.php');
?>

apt-get install php4-gd php4-pgsql /etc/init.d/apache restart

Voila, on peux maintenant suivre les cdr sur :

https://192.168.1.3/stats/

CDR postgres Asterisk
18 juin 2008, par safou

Merci,d’abord pour ce tuto, ça fait un bout temps que j’en cherchais un, mais mon petit souci, quand je lance le apt-get il ne trouve rien à telecharger, donc est ce qu’il y a une autre source depuis.


Warning: touch() [function.touch]: Utime failed: Permission denied in /usr/share/spip/ecrire/inc/genie.php on line 81