CDR File Module

From Yate Documentation
Revision as of 17:26, 19 March 2013 by Dana (Talk | contribs)

Jump to: navigation, search

Cdrfile is a module that receive a "chan.cdr" message (maybe from cdrbuild) and is writing the CDRs into a file.

Contents

List of available variables that could be used to construct a CDR record

Note: in order for a parameter to be available in the cdr, it has to be enabled in cdrbuild.conf.

The cdrwrite parameter is special, a boolean value of false will prevent the CDR from being written. This is to avoid generating CDR records for utility channels while still being able to track them.

  • ${time} - UNIX time
  • ${billid} - billing record id
  • ${chan} - channel used
  • ${address} - destination address
  • ${caller} - username/number of the device that initiated/received the call
  • ${called} - destination number
  • ${callername} - caller id
  • ${billtime} - billable call duration, starts from the point when the remote party actually answers the call
  • ${ringtime} - total time of the call
  • ${direction} - has a value of outgoing or incoming
  • ${status} - disposition of the call
  • ${reason} - reason for call disconnection

Configuration

cdrfile.conf:

[general]
; file: string: Name of the file to write the CDR to
; You should check that this file is log rotated - see /etc/logrotate.d/yate
; Example: file=/var/log/yate-cdr.tsv
;file=

; tabs: bool: Use tab-separated instead of comma-separated if format is missing
;tabs=true

; format: string: Custom format to use, overrides default. Each ${parameter}
;  is replaced with the value of that parameter in the call.cdr message

; tab-separated (.tsv)
;format=${time} ${billid} ${chan} ${address} ${caller} ${called} ${billtime} ${ringtime} ${duration} ${direction} ${status} ${reason}
 
; comma-separated (.csv)
;format=${time},"${billid}","${chan}","${address}","${caller}","${called}",${billtime},${ringtime},${duration},"${direction}","${status}","${reason}"

Set CDR billing

In many real-life situations CDR billing is done in seconds.

It's useful to set:

cdrbuild.conf

[general]
resolution=sec

Converting call time

If you need a human and machine readable representation of the time column you can use the following AWK script:

awk 'BEGIN{FS="\t";OFS="\t"} {$1=strftime("%Y%m%d%H%M%S",$1); print $0}' /var/log/yate-cdr.tsv

The above assumes TAB separated format, the ${time} parameter is in the first column (the $1 positional parameter) and the CDR file is in its usual place.

Adapt the script as needed. You can make the date/time more readable by inserting separators in the time format.


See also

Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers