Page tree
Skip to end of metadata
Go to start of metadata


This module logs call detail records (CDRs) directly to a PostgreSQL database, using the schema defined in the config file (freeswitch/conf/autoload_configs/cdr_pg_csv.conf.xml).

If a record insert fails for whatever reason, the record will be locally spooled to disk, in either CSV or SQL format (user-configurable).

 Click here to expand Table of Contents



To compile/install the module on Debian the PostgreSQL-Server-Devs are needed.

On Squeeze use aptitude to install. You can use:


For compiling the module from Freeswitch uncomment the module in modules.conf and add the module to freeswitch/conf/autoload_configs/modules.conf.xml for autoload.

CentOS 6.x:

Link your pg_config like this: ln -s /usr/pgsql-9.1/bin/pg_config /usr/bin

For CentOS to use PG 9.X instead of 8.3 (Standard w/git pull version) Series:

Modify Makefile for mod_cdr_pg_csv to look like this:

Database Setup

make sure postgresql is set as md5 login in the pg_hba.conf.

Schema Definition

The schema section of the config tells the module which channel variable to grab from the call's session, and how to handle them. The SQL INSERT query will be constructed using parameters defined in the schema section, and fields will be in the order they are listed in the config file. 

  • All fields are treated as strings (eg. they will have single quotes around them in the SQL query), unless specified otherwise.
  • If a channel variable resolves to an empty string, it will be cast to a SQL null, unless specified otherwise.
    • The reason for this is to be able to use more efficient, native PostgreSQL column types, such as timestamp (optionally with timezone), inet for storing IPv4/IPv6 addresses, and uuid for natively storing a UUID as a 128 bit binary value. PostgreSQL will not automatically cast empty strings for such fields, and therefore the values need to be handled by the module.

Defining a Field

The absolute minimum required to define a field is the channel variable name. Fields that do not specify a var attribute will be ignored. The following example will attempt to get a value for the channel variablecaller_id_number, and will treat it as a string.

To use a column name that is different to the channel variable name, simply override it in the field definition: