概述

freeswitch是一款简单好用的VOIP开源软交换平台。

在语音呼叫的过程中,话单是重要的计价和结算依据,话单的产生需要稳定可靠,可回溯。

fs中基本的话单模块mod_cdr_csv,可以满足大部分话单要求。

环境

centos:CentOS  release 7.0 (Final)或以上版本

freeswitch:v1.10.7

GCC:4.8.5

模块介绍

mod_cdr_csv模块默认编译安装,并有加载。

检查conf/autoload_configs/modules.conf.xml文件。

<load module="mod_cdr_csv"/>

cdr_csv模块会在通话结束后写入话单记录到文本文件,话单的格式根据配置的模板确定。

检查conf/autoload_configs/cdr_csv.conf.xml文件,默认配置如下。

<configuration name="cdr_csv.conf" description="CDR CSV Format">

<settings>

<!-- 'cdr-csv' will always be appended to log-base -->

<!--<param name="log-base" value="/var/log"/>-->

<param name="default-template" value="example"/>

<!-- This is like the info app but after the call is hung up -->

<!--<param name="debug" value="true"/>-->

<param name="rotate-on-hup" value="true"/>

<!-- may be a b or ab -->

<param name="legs" value="a"/>

<!-- Only log in Master.csv -->

<!-- <param name="master-file-only" value="true"/> -->

</settings>

<templates>

<template name="sql">INSERT INTO cdr VALUES ("${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}", "${accountcode}");</template>

<template name="example">"${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}","${accountcode}","${read_codec}","${write_codec}"</template>

<template name="snom">"${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}", "${accountcode}","${read_codec}","${write_codec}","${sip_user_agent}","${call_clientcode}","${sip_rtp_rxstat}","${sip_rtp_txstat}","${sofia_record_file}"</template>

<template name="linksys">"${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}","${accountcode}","${read_codec}","${write_codec}","${sip_user_agent}","${sip_p_rtp_stat}"</template>

<template name="asterisk">"${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>

<template name="opencdrrate">"${uuid}","${signal_bond}","${direction}","${ani}","${destination_number}","${answer_stamp}","${end_stamp}","${billsec}","${accountcode}","${userfield}","${network_addr}","${regex('${original_caller_id_name}'|^.)}","${sip_gateway_name}"</template>

</templates>

</configuration>

默认配置中,fs使用“example”模板写话单文件“log/cdr_csv/Master.csv”。

其中几个比较有用的配置项解释如下。

<param name="debug" value="true"/>

debug参数在调试时比较有用,作用是通话结束后通过“info“命令打印出AB路的全部通道变量,这样就可以更容易知道在话单模板中应该如何设置自己需要的字段。

2023-07-05 10:48:13.704735 [INFO] mod_cdr_csv.c:219 CHANNEL_DATA:

Channel-State: [CS_REPORTING]

Channel-Call-State: [HANGUP]

Channel-State-Number: [11]

Channel-Name: [sofia/external4080/13712345678@10.55.55.138:5090]

Unique-ID: [5d7f96d0-1ade-11ee-a6e6-ef73ce267dbc]

Call-Direction: [outbound]

2023-07-05 10:48:13.724676 [INFO] mod_cdr_csv.c:219 CHANNEL_DATA:

Channel-State: [CS_REPORTING]

Channel-Call-State: [HANGUP]

Channel-State-Number: [11]

Channel-Name: [sofia/external/10011@10.55.55.138]

Unique-ID: [5d7e804c-1ade-11ee-a6dd-ef73ce267dbc]

Call-Direction: [inbound]

<param name="legs" value="ab"/>

话单记录可以选择写入“a“、”b“和”ab“,分别表示A路话单,B路话单,AB路双话单。

"10011","10011","13712345678","out_to_in_public","2023-07-05 10:48:04","2023-07-05 10:48:09","2023-07-05 10:48:13","9","4","NORMAL_CLEARING","5d7f96d0-1ade-11ee-a6e6-ef73ce267dbc","","","","","outbound","16","recv_bye","sip:200","10.55.55.138",""

"10011","10011","13712345678","out_to_in_public","2023-07-05 10:48:04","2023-07-05 10:48:09","2023-07-05 10:48:13","9","4","NORMAL_CLEARING","5d7e804c-1ade-11ee-a6dd-ef73ce267dbc","5d7f96d0-1ade-11ee-a6e6-ef73ce267dbc","","","","inbound","16","send_bye","","10.55.55.138",""

<param name="master-file-only" value="true"/>

当我们需要根据“accountcode”来区分客户的话单模板格式时,fs默认会根据模板名称产生多个csv文件,该参数设置话单记录只写入Master.csv文件。

自定义话单模板

修改conf/autoload_configs/cdr_csv.conf.xml文件,配置如下。

<template name="example">"${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}","${accountcode}","${read_codec}","${write_codec}","${direction}","${hangup_cause_q850}","${sip_hangup_disposition}","${proto_specific_hangup_cause}","${network_addr}","${rtp_audio_in_mos}"</template>

模板中的字段如果不能满足实际需求,可以通过debug模式查看AB路所有的通道变量。

多模板场景的话单

某些情况下,我们需要对不同的场景输出不同的话单格式。

fs提供通道变量“accountcode”来区分模板场景。

修改dialplan拨号计划如下。

<action application="export" data="accountcode=asterisk" />

在log/cdr_csv目录下产生两个文件“Master.csv”和”asterisk.csv”。

cat asterisk.csv

"asterisk","10011","13712345678","out_to_in_public",""10011" <10011>","sofia/external4080/13712345678@10.55.55.138:5090","","","","2023-07-05 15:30:34","2023-07-05 15:30:38","2023-07-05 15:30:55","21","17","NORMAL_CLEARING","","d44d3fe8-1b05-11ee-a6a1-875ed88826f8",""

"asterisk","10011","13712345678","out_to_in_public",""10011" <10011>","sofia/external/10011@10.55.55.138","","bridge","{sip_h_Route=<sip:10.55.55.138:5090;lr>,sip_invite_call_id=abaa3d90-95a8-123c-7ebf-b6fcd7842446,sip_invite_domain=test01.9999.com,sip_cid_type=pid}{}sofia/external4080/sip:13712345678@10.55.55.138:5090","2023-07-05 15:30:34","2023-07-05 15:30:38","2023-07-05 15:30:55","21","17","NORMAL_CLEARING","","d44c4570-1b05-11ee-a697-875ed88826f8",""

cat Master.csv

"10011","10011","13712345678","out_to_in_public","2023-07-05 15:30:34","2023-07-05 15:30:38","2023-07-05 15:30:55","21","17","NORMAL_CLEARING","d44d3fe8-1b05-11ee-a6a1-875ed88826f8","","asterisk","","","outbound","16","recv_bye","sip:200","10.55.55.138",""

"10011","10011","13712345678","out_to_in_public","2023-07-05 15:30:34","2023-07-05 15:30:38","2023-07-05 15:30:55","21","17","NORMAL_CLEARING","d44c4570-1b05-11ee-a697-875ed88826f8","d44d3fe8-1b05-11ee-a6a1-875ed88826f8","asterisk","","","inbound","16","send_bye","","10.55.55.138",""

话单文件分割

mod_cdr_csv模块提供了一个api命令“cdr_csv rotate“,可以根据实际需要来分割话单文件。

freeswitch@pxy137> cdr_csv rotate

+OK

2023-07-05 14:55:21.524681 [NOTICE] mod_cdr_csv.c:127 Rotated CDR logfile ../log/cdr-csv/Master.csv

-rw-r--r--. 1 root root    0 Jul  5 14:55 Master.csv

-rw-r--r--. 1 root root 5914 Jul  5 10:48 Master.csv.2023-07-05-14-55-21

总结

freeswitch的基本话单模块mod_cdr_csv,输出稳定高效,配置灵活,字段选择多。

空空如常

求真得真

freeswitch的mod_cdr_csv模块的更多相关文章

  1. freeswitch的话单模块

    概述 最近因为业务需要,在看freeswitch中话单相关的一些模块. 在voip的使用过程中,话单是重要的基础模块,涉及到计费和问题查找. 呼叫话单最重要的一点是稳定,不能有错误或遗漏. 本章对fs ...

  2. FreeSWITCH 加载模块过程解读

    今天来学习FreeSWITCH 加载模块过程. 哪些模块需要编译,是由源码下的 modules.conf 文件决定的. 哪些模块在程序启动时自动加载,是由 freeswitch/conf/autolo ...

  3. freeswitch插件式模块接口实现方式

    概述 freeswitch的外围模块是插件式的,可以动态的加载和卸载,使用起来非常的灵活和方便. 如果我们自己来设计一个开源的代码框架,相信这种插件式的模块结构是非常适合多人合作的模式. 本文对fs的 ...

  4. freeswitch的mod_curl模块

    概述 有时候,我们需要在呼叫的过程中,或过程后调用web api接口. freeswitch的mod_curl模块可以很方便的实现web api的接口调用. mod_curl模块默认不安装,需要进入模 ...

  5. freeswitch使用mod_shout模块播放mp3

    概述 freeswitch 在对VOIP语音通话中,可以通过playback命令播放IVR语音文件. 默认情况下,freeswitch支持wav文件,也可以直接播放VOIP中常见编解码的G711文件. ...

  6. freeswitch编译mod_av模块

    需要先编译libav库 编译libav下载:git clone https://freeswitch.org/stash/scm/sd/libav.git cd libav ./configure - ...

  7. 《FreeSWITCH: VoIP实战》:SIP 模块 - mod_sofia

    SIP 模块是 FreeSWITCH 的主要模块,所以,值得拿出专门一章来讲解. 在前几章时里,你肯定见过几次 sofia 这个词,只是或许还不知道是什么意思.是这样的,Sofia-SIP 是由诺基亚 ...

  8. freeswitch新增模块API

    概述 上一章我们讲解了freeswitch的源码基本结构,以及如何新增一个插件式模块. freeswitch的架构非常适合这种业务开发模式,即以freeswitch的基本功能为开发平台,新增插件式模块 ...

  9. Freeswitch 添加可转码的G729编码

    默认情况下Freeswitch自带的G729模块是pass-through-并不支持转码. 不过我们依然有个好奇的心, 所以我们决定添加一个支持G729转码的模块到Freeswitch. 1. 下载m ...

  10. Freeswitch配置之sofia

    SIP模块 - mod_sofia SIP 模块是 FreeSWITCH的主要模块. 在 FreeSWITCH中,实现一些互联协议接口的模块称为 Endpoint.FreeSWITH支持很多的 End ...

随机推荐

  1. 微信小程序隐藏页面滚动条

    开发小程序时,经常会碰到页面长度超过屏幕高度,然后下拉时会出现滚动条,对于一些有强迫症的人来说是不可忍受的. 网上看了好多,写的.都评论有起作用或者不起作用的. 我在这分享一个全局隐藏滚动条的方式. ...

  2. 13-css兼容性处理(添加前缀)

    const { resolve } = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') const M ...

  3. ts、typescript、enum、枚举、ts 获取枚举对应的类型、获取 enum 的 key 和 value

    ts.typescript.enum.枚举.ts 获取枚举对应的类型 // 假设我一个枚举 enum ENUM_TYPE { ALL = 'all', SOME = 'some', LITTLE = ...

  4. 笔记:C++学习之旅---try语句和异常处理

        异常处理机制为程序中异常检测和异常处理这两部分的协作提供支持,在C++语言中,异常处理包括:     *throw表达式(throw expression),异常检测部分使用throw表带是来 ...

  5. #PowerBi 10分钟学会,以X为结尾的聚合函数

    前言 在Power BI中,我们经常需要对数据进行聚合计算,比如求和.求平均.求最大值等. Power BI提供了一系列的聚合函数,可以用来对表中列的值进行聚合然后返回一个值.这些函数通常只需要一个参 ...

  6. 雪球 app 实战(1)

    开头 因为理论篇结束之后,需要一个实战,估选用了雪球app作为一个作业 业务场景: 雪球 app 自选设置(入口位于 行情 模块) 作业内容 使用 百度脑图 编写 思维导图 [自选设置]模块的测试用例 ...

  7. 2022-11-04:给定一个正数n,表示有多少个节点 给定一个二维数组edges,表示所有无向边 edges[i] = {a, b} 表示a到b有一条无向边 edges一定表示的是一个无环无向图,也

    2022-11-04:给定一个正数n,表示有多少个节点 给定一个二维数组edges,表示所有无向边 edges[i] = {a, b} 表示a到b有一条无向边 edges一定表示的是一个无环无向图,也 ...

  8. 2022-08-22:给定一个数组arr,长度为n,最多可以删除一个连续子数组, 求剩下的数组,严格连续递增的子数组最大长度。 n <= 10^6。 来自字节。5.6笔试。

    2022-08-22:给定一个数组arr,长度为n,最多可以删除一个连续子数组, 求剩下的数组,严格连续递增的子数组最大长度. n <= 10^6. 来自字节.5.6笔试. 答案2022-08- ...

  9. 2021-06-03:布尔运算。给定一个布尔表达式和一个期望的布尔结果 result,布尔表达式由 0 (false)、1 (true)、& (AND)、 | (OR) 和 ^ (XOR) 符号组成。

    2021-06-03:布尔运算.给定一个布尔表达式和一个期望的布尔结果 result,布尔表达式由 0 (false).1 (true).& (AND). | (OR) 和 ^ (XOR) 符 ...

  10. MySql的数据存储之B+树(浅谈)

    一.MySql的实际存储位置 B+树是MySql数据结构的主流存储方式,包括InnoDB和MYISAM引擎,它们的默认存储结构都是B+树 了解B+树前,我们先要知道MySql 的实际存储位置在哪? 有 ...