Manual Installation of CDR STATS on an Existing Ubuntu FreeSWITCH Server

Manual Installation of CDR STATS on an Existing Ubuntu FreeSWITCH Server

CDR STATS

Pre-requisite

Make sure you have followed our [FreeSWITCH installation] How to install FreeSWITCH on Ubuntu 22.04 article

Installation and Configuration

Compile and Install module `mod_cdr_pg_csv`

open `/usr/local/src/freeswitch-1.10.10.-release/modules.conf` in your favorite editor and un-comment `event_handlers/mod_cdr_pg_csv`

cd /usr/local/src/freeswitch-1.10.10.-release/

make mod_cdr_pg_csv-install

Update db-info param in  `/etc/freeswitch/autoload_configs/cdr_pg_csv.conf.xml` for database connection

#Make sure the postgres connection string is properly configured

<param name="db-info" value="host=localhost dbname=dbname user=user password='password' connect_timeout=10" />

Create PG table for CDR

# mod_cdr_pg_csv provides sample cdr table schema, copy the table schema from following path/file

cat /usr/local/src/freeswitch-1.10.10.-release/src/mod/event_handlers/mod_cdr_pg_csv/scripts/create.sql

Here are the contents of `create.sql`

-- Sample CDR table schema

 

create table cdr (

    id                        serial primary key,

    local_ip_v4               inet not null,

    caller_id_name            varchar,

    caller_id_number          varchar,

    destination_number        varchar not null,

    context                   varchar not null,

    start_stamp               timestamp with time zone not null,

    answer_stamp              timestamp with time zone,

    end_stamp                 timestamp with time zone not null,

    duration                  int not null,

    billsec                   int not null,

    hangup_cause              varchar not null,

    uuid                      uuid not null,

    bleg_uuid                 uuid,

    accountcode               varchar,

    read_codec                varchar,

    write_codec               varchar,

    sip_hangup_disposition    varchar,

    ani                       varchar

);

Create the table in db-fs database using `psql` console or pgadmin4

Check the ownership of table by `\dt` on psql console and make sure user `user`  is the owner of the table or have atleast write/INSERT access on the `cdr` table

-- To change the owner of the table run following query

ALTER TABLE cdr OWNER TO user

To load the module into freeswitch process open `fs_cli` and run following command

load mod_cdr_pg_csv

To always autoload the CDR module when FreeSWITCH starts. Add following line in `/etc/freeswitch/autoload_configs/modules.conf.xml`

<load module="mod_cdr_pg_csv"/>

To check if the module is loaded, run following command on `fs_cli` (result should be ‘`true`’)

module_exists mod_cdr_pg_csv

Follow us TwitterFacebookLinkedIn

Open Source Listing

Previous Post
Next Post

Leave a Reply