Mod cdr csv

From FreeSWITCH Wiki

Jump to: navigation, search

This module allows you to log call detail records (CDRs) in a text file using text generation templates.

The default configuration is located in freeswitch/conf/autoload_configs/cdr_csv.conf.xml


Contents

XML structure

Variables in a template

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

Here is a sample cdr of a call that was successful, we'll use this to refer to each variable below.

"xtec","2185738219","919814440333","default",""2185738219" <2185738219>","sofia/in/2185738219@89.212.283.238:5060","sofia/out/+919814440333@222.199.89.27","bridge","sofia/out/+919814440203@222.199.89.27","2008-02-11 07:01:49","2008-02-11 07:02:07","2008-02-11 07:27:13","1524","1506","NORMAL_CLEARING","","c60a1f09-ce61-47d3-a806-82bd2c9a4b6a","89.202.183.238"

this particular cdr was made with the following template (note, it doesn't have bleg_uuid)

<template name="legacy" >"${accountcode}","${caller_id_number}","${destination_number}","${context}", ${caller_id}","${channel_name}","${bridge_channel}","${last_app}","${last_arg}","${start_stamp}", "${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${amaflags}", "${uuid}","${userfield}"</template>

Some significant variables

accountcode

An arbitrary value given at whim. Useful for billing and segregating calls by account. This is the accountcode of the aleg. In the sample above its xtec.

amaflags

Automatic Message Accounting, an archaic system that "flags" CDR for post-processing. Commonly used flags are billing, default, documentation, omit.

answer_stamp

Timestamp when the call was answered, in ISO 8601 format (YYYY-MM-DD hh:mm:ss)

billsec

The answered or billing span of the calls in seconds, i.e. "answer_stamp - end_stamp". Should only be > 0 in calls where HANGUP_CAUSE == NORMAL_CLEARING (16).

bleg_uuid

The uuid of the bleg, i.e. the called party or terminating end.

bleg_uuidaccountcode

The accountcode of the bleg_uuid in the call.

bridge_channel

The channel name of the bleg that the aleg was bridged to. Eg. sofia/out/+919814440333@222.199.89.27

call_clientcode

caller_id

caller_id_name

See Channel_Variables#caller_id_name

caller_id_number

See Channel_Variables#caller_id_number

channel_name

This is the channel_name of the aleg originating end. In this case its sofia/in/2185738219@89.212.283.238:5060.

context

The context where the call first entered the dialplan, in this case default.

destination_number

This is the number (rather, extension) specified by the aleg. In the example above its 919814440333. The dialplan can peform any mutation on this number before its actually dialed out (in the case above a + is added).

duration

The entire duration of the call, end to end in seconds, i.e. "start_stamp - end_stamp". Duration should always be >= billsec.

end_stamp

Timestamp when the call was hung up, in ISO 8601 format (YYYY-MM-DD hh:mm:ss)

hangup_cause

See Hangup_causes

last_app

The last application run by the call, in the case of our example, its bridge.

last_arg

The arguments passed to the last_app, i.e. sofia/out/+919814440203@222.199.89.27

read_codec

See Channel_Variables#read_codec

sip_rtp_rxstat

sip_user_agent

sofia_record_file

start_stamp

Timestamp when the call was started, in ISO 8601 format (YYYY-MM-DD hh:mm:ss)

userfield

A field to set your own custom values. For example

     <action application="set" data="userfield=${network_addr}"/>

uuid

A unique identifier for the call. A UUID is a block of 16 bytes ref. This is the uuid of the aleg of the call, i.e. the calling party or origination end. According to ref UUIDs are formatted as: 00112233-4455-6677-8899-AABBCCDDEEFF

write_codec

See Channel_Variables#write_codec

Load the CSV into Mysql

here is a simple perl scipt to help you load the CDR into the db (someone who knows perl could probably fix this)

Load CDR to Mysql

Personal tools
Community