Mod cdr sqlite

From FreeSWITCH Wiki
Jump to: navigation, search

The Basics

This module logs call detail records (CDRs) directly to a SQLite database, using templates to define the field order for the SQL insert. These templates along with the default configuration are stored in the file freeswitch/conf/autoload_configs/cdr_sqlite.conf.xml.

The database specified by the parameter db-name is automatically created in the same directory as the FreeSWITCH core database (specified by the -db command-line switch, or /usr/local/freeswitch/db by default). The file extension .db is automatically appended to the db-name.

 <param name="db-name" value="cdr"/>

The DB table name is specified by the parameter db-table (cdr by default).

 <param name="db-table" value="cdr"/>

If the table does not exist, the mod_cdr_sqlite will create it automatically, using the following default table schema:

 CREATE TABLE tablename (
   caller_id_name VARCHAR,
   caller_id_number VARCHAR,
   destination_number VARCHAR,
   context VARCHAR,
   start_stamp DATETIME,
   answer_stamp DATETIME,
   end_stamp DATETIME,
   duration INTEGER,
   billsec INTEGER,
   hangup_cause VARCHAR,
   uuid VARCHAR,
   bleg_uuid VARCHAR,
   account_code VARCHAR
 );

The template that is used for the default field order is defined by the following line (which uses "example" in the default installation).

 <param name="default-template" value="example"/>

Variables in a Template

Variables are given in the form ${varname}. For an overview of variables, check Channel Variables. You can specify any channel variable.

Template variables can be to API calls as well, like:

<template name="custom_timestamp">"${expr(${end_epoch}-${my_timestamp})}"</template>

Some Significant Variables

See mod_cdr_csv