text
stringlengths
0
152
Create a separate CSV file for each different value of the accountcode CDR variable.
The default is yes.
The order of CDR variables in CSV files created by the cdr_csv module is:
<accountcode>,<src>,<dst>,<dcontext>,<clid>,<channel>,<dstchannel>,<lastapp>, \
<lastadata>,<start>,<answer>,<end>,<duration>,<billsec>,<disposition>, \
<amaflags>[,<uniqueid>][,<userfield>]
Place the following lines into /etc/asterisk/cdr.conf:
[general]
enable=yes
[csv]
usegmtime=yes ; log date/time in GMT. Default is "no"
loguniqueid=yes ; log uniqueid. Default is "no"
loguserfield=yes ; log user field. Default is "no"
accountlogs=yes ; create separate log file for each account code. Default is "yes"
;newcdrcolumns=yes ; Enable logging of post-1.8 CDR columns (peeraccount,linkedid,sequence)
; Default is "no".
Save it, chown it, and reload the CDR module.
$ chown asterisk:asterisk /etc/asterisk/cdr.conf
$ sudo asterisk -rx 'module reload cdr'
cdr_custom
This CDR backend allows for custom formatting of CDR records in a logfile. This
module is most commonly used for customized CSV output. The configuration file
used for this module is /etc/asterisk/cdr_custom.conf. A single section called
[mappings] should exist in this file. The [mappings] section contains mappings
between a filename and the custom template for a CDR. The template is specified
using Asterisk dialplan functions.
The following example shows a sample configuration for cdr_custom that enables a
single CDR logfile, Master.csv. This file will be created as /var/log/asterisk/cdr-custom/
Master.csv. The template that has been defined uses both the CDR() and CSV_QUOTE()
dialplan functions. The CDR() function retrieves values from the CDR being logged.
Call Detail Records
|
361
The CSV_QUOTE() function ensures that the values are properly escaped for the CSV
file format:
[mappings]
Master.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},
${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},
${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},
${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},
${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},
${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration)})},
${CSV_QUOTE(${CDR(billsec)})},${CSV_QUOTE(${CDR(disposition)})},
${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},
${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})}
In the actual configuration file, the value in the Master.csv mapping
should be on a single line.
cdr_manager
The cdr_manager backend emits CDRs as events on the Asterisk Manager Interface
(AMI), which we discussed in detail in Chapter 17. This module is configured in
the /etc/asterisk/cdr_manager.conf file. The first section in this file is the [general]
section, which contains a single option to enable this module (the default value is no):
[general]
enabled = yes
The other section in cdr_manager.conf is the [mappings] section. This allows for
adding custom CDR variables to the manager event. The syntax is:
CDR variable => Header name
Here is an example of adding two custom CDR variables:
[mappings]
rate => Rate
carrier => Carrier
With this configuration in place, CDR records will appear as events on the manager
interface. To generate an example manager event, we will use the following dialplan
example:
exten => 110,1,Answer()
same => n,Set(CDR(rate)=0.02)
same => n,Set(CDR(carrier)=BS&S)
same => n,Hangup()
362