System information

cdr_csv
The cdr_csv module is a very simple CDR backend that logs CDRs into a CSV (comma
separated values) file. The file is /var/log/asterisk/cdr-csv/Master.csv. As long as CDR
logging is enabled in cdr.conf and this module has been loaded, CDRs will be logged
to the Master.csv file.
While no options are required to get this module working, there are some options that
customize its behavior. These options, listed in Table 24-5, are placed in the [csv]
section of cdr.conf.
Table 24-5. cdr.conf [csv] section options
Option Value/Example Notes
usegmtime no Log timestamps using GMT instead of local time. The default is no.
loguniqueid no Log the uniqueid CDR variable. The default is no.
loguserfield no Log the userfield CDR variable. The default is no.
accountlogs yes 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>]
cdr_custom
This CDR backend allows for custom formatting of CDR records in a log file. 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 log file, 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. 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)})},
532 | Chapter 24:System Monitoring and Logging