Asterisk CDR的CSV格式的应用

Asterisk CDR的CSV格式的应用

  如今有了图形界面,一般都用数据库方式存储Asterisk的CDR(Call Detail Record)记录.其中最常用的就是Mysql了.由于License的关系,Asterisk CDR对Mysql的支持是放在add-ones中的.但在trixbox和Elastix中,都启用了cdr_mysql.但这并不是asteriskCDR的全部.

  在一个项目中,客户不愿意放弃他们现有的计费系统(支持串口或文件获取数据),而且也找不到计费系统的开发商来支持.这个时候,Asterisk的默认CDR方式就派上用场了.

  Asterisk的cdr_csv.so模块将CDR数据保存在/var/log/asterisk/cdr_csv/目录下的Master.csv文件中(看到csv,联想到什么?--对了,就是excel支持的一种以逗号分隔数据域的文本格式,可以直接导入到excel中的)

  Master.csv字段(数据域)顺序是
"${CDR(clid)}","${CDR(src)}","${CDR(dst)}","${CDR(dcontext)}","${CDR(channel)}","${CDR(dstchannel)}","${CDR(lastapp)}","${CDR(lastdata)}","${CDR(start)}","${CDR(answer)}","${CDR(end)}","${CDR(duration)}","${CDR(billsec)}","${CDR(disposition)}","${CDR(amaflags)}","${CDR(accountcode)}","${CDR(uniqueid)}","${CDR(userfield)}"

各个字段的定义如下
${CDR(clid)} = callerid for the call (with the name)

${CDR(src)} = callerid number for the call

${CDR(dst)} = destination extension

${CDR(dcontext)} = Destination context

${CDR(channel)} = Src channel

${CDR(dstchannel)} = Destination channel if appropriate

${CDR(lastapp)} = this is the last application in the dialplan used, on an outgoing call this will be DIAL.

${CDR(lastdata)} = these are the parameters given to the last application used in the dialplan

${CDR(start)} = time of the start of the call

${CDR(answer)} = time when the call was answered

${CDR(end)} = time when the call got hung up

${CDR(duration)} = duration of the call

${CDR(billsec)} = duration of the actual call (without the ringing)

${CDR(disposition)} = status of the call (ANSWERED, BUSY, NO ANSWER)

${CDR(amaflags)} = flag for the type of CDR (can be set in a.o. sip.conf)
  default: Sets the system default.
  omit: Do not record calls.
  billing: Mark the entry for billing
  documentation: Mark the entry for documentation.

${CDR(accountcode)} = the accountcode as set for this channel with for example SetAccountcode in the dialplan (Extensions.conf) or in the channel configuration file (e.g. per user in sip.conf, iax.conf and per channel in zaptel.conf)

${CDR(uniqueid)} = a unique id for this call

${CDR(userfield)} = a userfield set by the dialplan command SetCDRUserfield

  由此我们可以根据这些字段的定义将Master.csv文件转化为计费软件需要的内容
实际上,Asterisk CDR也考虑到这点,在/etc/asterisk/目录下有个cdr_custom.conf文件可以让你从这些字段中自定义需要的内容,这样我们获得CDR记录的目录变为/var/log/asterisk/cdr_cusotm
  呵呵,再拓展一下,可以将Asterisk的csv格式的文件重定向到串口,呵呵 这样就更省事了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值