FreeSWITH+SIPCAPTURE安装配置全记录(centOS7)


sipcapture的首页和简介

1、依赖下载&安装

官网
  如果linux服务器可以连接外网,那么安装sipcapture非常简单,跟着官网步骤几步就完成了。
  有时候服务器外网不通(例如公司的测试环境),那就需要先配置代理(需要知道代理服务器地址和端口)。配置curl命令的http/https全局代理,需要修改 /etc/profile 文件:

vim /etc/profile,然后添加:

http_proxy=http://username:password@ntproxy.qa.nt.xxxxxxxcorp.com:8080/
https_proxy=http://username:password@ntproxy.qa.nt.xxxxxxxcorp.com:8080/
export http_proxy
export https_proxy

  如果没有密码限制,则以上内容可以修改为以下内容:

http_proxy=http://ntproxy.qa.nt.xxxxxxxcorp.com:8080/
https_proxy=http://ntproxy.qa.nt.xxxxxxxcorp.com:8080/
export http_proxy
export https_proxy

  若只针对某个用户而言,则修改 ~/.bash_profile 文件,添加相同内容。修改完成后,记得注销并重新登录,否则不生效。代理配置完后执行
curl -s https://packagecloud.io/install/repositories/qxip/sipcapture/script.rpm.sh | sudo bash,curl命令会自动完成相关依赖的下载,成功后提示:在这里插入图片描述
同时在/etc/zypp/repos.d/或/etc/yum.repos.d/路径下生成qxip_sipcapture.repo文件。
(上面这一步也可以直接把https://packagecloud.io/install/repositories/qxip/sipcapture/script.rpm.sh的内容复制到本地同名文件中,然后执行bash ./script.rpm.sh。甚至干脆手动在/etc/yum.repos.d/路径下创建qxip_sipcapture.repo文件,文件内容就是https://packagecloud.io/install/repositories/qxip/sipcapture/config_file.repo?os=centos&dist=7&source=script的内容)

2、sipcapture架构(各组件关系)

在这里插入图片描述

3、Homer-app的安装&配置

官网
  Homer-app是个基于golang的前端页面,可以直接展示捕获到的sip或者rtp等消息,或者说就是GUI.

环境需求:

在这里插入图片描述
如何安装postgres11

安装

yum install homer-app

启动

先下载homer-app.service文件,依次执行:
cp homer-app.service /etc/systemd/system/
systemctl daemon-reload
systemctl start homer-app
systemctl enable homer-app

配置
  1. 进入安装目录/usr/local/bin,依次执行以下命令:
    在本地postgres中创建homer-app用户
    ./homer-app -create-homer-user -database-root-user=postgres -database-host=localhost -database-root-password=postgres
    检查db用户:
    ./homer-app -show-db-users -database-root-user=postgres -database-host=localhost -database-root-password=postgres
    创建配置文件db:
    ./homer-app -create-config-db -database-root-user=postgres -database-host=localhost -database-root-password=postgres -database-homer-user=homer_user
    创建数据db:
    ./homer-app -create-data-db -database-root-user=postgres -database-host=localhost -database-root-password=postgres -database-homer-user=homer_user
    db赋权:
    ./homer-app -create-homer-role -database-root-user=postgres -database-host=localhost -database-root-password=postgres -database-homer-data=homer_data -database-homer-config=homer_config
    填充(populate)db:
    ./homer-app -populate-table-db-config
    从webapp_config.json中读取配置文件:
    ./homer-app -upgrade-table-db-config
    此外,每次对webapp_config.json进行更新后,都要执行以下两个命令刷新配置文件:
    ./homer-app -populate-table-db-config -force-populate

    ./homer-app -populate-table-db-config -force-populate -populate-table=mapping_schema -populate-table=user_settings

  2. 相关配置。
    默认配置文件位置:/usr/local/homer/etc/webapp_config.json。这个文件的"system_settings"配置项可以关注下,设置了homer-app的日志文件地址、日志级别等信息,这对于排障至关重要:
    在这里插入图片描述

  3. 可能遇到的问题。
      在对homer-app进行postgres相关配置时,可能会遇到Cant connect to postgresql的报错panic: pq: Ident authentication failed for user “postgres”。解决这个问题首先要确保postgres默认用户(postgres)的密码为postgres,如果不是的话要修改默认密码;其次要修改pg_hba.conf(我用的postgres版本是11,默认位置在/var/lib/pgsql/11/data/):
    在这里插入图片描述
      如果一切正常的话,访问服务器Ip的9080端口就能看到homer-app的前端页面。但是运气不好的话可能遇到各种各样奇葩问题,前端页面没办法正常使用。如果有报错信息,都会写在homer-app.log中。个人常用的的调试方法:
    1、首先停掉homer-app服务: systemctl stop homer-app
    2、去webapp_config.json中的“system_settings”配置项中,“loglevel”改为debug,“logstdout”改为true,然后刷新配置文件(具体命令参考上面)
    3、在安装目录(usr/local/bin/)下直接运行homer-app:./homer-app,然后访问9080端口。这时homer-app的运行日志会直接打印在控制台中,更直观。

4、heplify-server的安装&配置

官网
  heplify-server就是架构图中的"CAPTURE SERVER"。

环境需求:

在这里插入图片描述

安装

yum install heplify-server

启动

先下载heplify-service.service脚本,再依次执行:
cp heplify-server.service /etc/systemd/system/
systemctl daemon-reload
systemctl start heplify-server
systemctl enable heplify-server

配置
  1. 关于配置文件。
    在执行完heplify-service.service脚本之后,配置文件的位置在/etc/heplify-server.toml。配置文件中有许多配置项,这里不详细解释各个配置项的含义了。主要需要注意的是postgres的相关配置,DBUser和DBPass都要设置成“postgres":
    在这里插入图片描述
    改完配置文件后我的习惯是重启heplify-server服务systemctl restart heplify-server
  2. 关于日志。
    就离谱,heplify-server的日志保存路径竟然就在根路径 /,还没法改。。。如果有人知道怎么改的话可以告我下,谢谢了。
  3. 可能遇到的问题。
    heplify-server无法连接数据库的问题:
    在这里插入图片描述
    上图框出来的127.0.0.1:5432就是是postgres服务。这个问题的主要原因是heplify-server.toml的位置不对,

5、freeswitch的配置

  freeswitch本身支持hep协议,进行一些配置之后可以直接当成CAPTURE AGENT。题外话:除了freeswitch还有很多HEP/EEP Agent,最简单的应该是heplify了,官网的quick install也是用heplify举例的。

  1. 参照官网的fs配置:
    /autoload_config/sofia.conf.xml中:
    <param name="capture-server" value="udp:127.0.0.1:9060"/>
    /sip_profiles/internal.xml中:
    <param name="sip-capture" value="yes"/>
    进入fs的客户端fs_cli,输入:
    sofia global capture on
    (上面xml文件修改完之后别忘了reloadxmlsofia profile internal rescan使修改生效)

  2. 遇到的问题。
    官网对sofia.conf.xml的配置是:
    <param name="capture-server" value="udp:192.168.0.1:9060"/>
      起初进行了相同的配置,但是在homer-app中看不到任何消息。先换heplify试了下:安装heplify:yum install heplify,然后进入安装目录usr/local/bin中直接运行./heplify。然后用fs打一通电话,发现homer-app工作正常显示出了sip消息。
      那就怀疑是fs没有捕获到sip消息,于是用tcpdump+wireshark对9060端口进行udp抓包并解析,发现是有sip数据的:
    在这里插入图片描述
    这说明fs可以捕获到sip消息。难道是heplify-server有问题,没有接收到sip消息?看下配置文件heplify-server.toml中的HEPAddr配置项是0.0.0.0:9060,确实是监听的本地9060端口。最后是怀疑192.168.0.1这个地址的问题,ping了一下192.168.0.1这个地址发现ping不通,于是改成127.0.0.1问题解决(直接写服务器ip也是可以的)。关于这几个地址的区别:
    在这里插入图片描述

6、使用远端postgres(db中心化)

  1. postgres。既然使用的是远端db,那本地不再需要安装postgres,当然也就不需要在本地postgres中创建homer-app用户了。
  2. homer-app。配置文件webapp_config.json中"database_data"和"database_config"两个节点中的"host"配置改为远端postgres的服地址,同时"pass"和"user"都要配置成远端postgres的用户名和密码:
    在这里插入图片描述
  3. heplify-server。配置文件heplify-server.toml中,"DBAddr"一项改为远端postgres的地址,同时"DBPass"和"DBUser"都要配置成远端postgres的用户名和密码:
    在这里插入图片描述

7、一通话务的多腿关联(leg correlation)

  很多时候,主被叫并不是注册在同一台fs上的。如下图所示,主被叫分别注册在两台fs上。
在这里插入图片描述

  1. 修改fs1的/diaplan/public.xml,在bridge到fs2之前的地方,加入如下的路由:
<extension name="x-cid-public" continue="true">
	<condition>
		<action application="set" data="sip_h_X-cid=${sip_call_id}"/>
	</condition>
</extension>

  解释:在fs1将sip传递给fs2之前,获取legA的call_id,并加入到invite消息中的sip header中,如图:
在这里插入图片描述
2. 修改fs2的heplify-server配置文件:/etc/heplify-server.toml
在这里插入图片描述
  解释:告诉fs2上的heplify-server,使用fs1传来的sip消息中的X-cid进行关联。如果部署了多台heplify-server,那每一台的heplify-server.toml都要配!!!效果:
在这里插入图片描述
3. 一个问题。下面所示为完整的sip流,可以看到主叫—fs1的sip流、fs2—被叫的sip流都正常,这两个sip流也成功关联(否则不会出现在同一个图中),但是fs1—fs2的sip流却缺失,不知道哪里的配置有问题,需要继续研究下。
在这里插入图片描述
更新:后来使用CaptAgent代替fs进行sip捕获,获得了完整的sip流如下图。如果homer7上还看不到成功关联的sip流,需要在homer上增加mappings。如果按照前文所述,也使用“X-cid”作为通道变量进行多腿关联的话,则不需要再设置homer,因为homer会默认使用名为“X-cid”的通道变量进行关联。
在这里插入图片描述
看来还是fs作为sip capture时哪里配置有问题。

8、CaptAgent的安装和配置

官网
  fs本身可以已经可以作为capture agent进行sip消息的捕获和监控。但是CaptAgent对于QoS、MOS、RTP/RTCP等和语音质量相关指标的监控分析能力是fs不具备的。

安装
依赖

Captagent 6.2+版本需要安装libuv,本人是CentOS7,直接执行:

yum -y install json-c-devel expat-devel libpcap-devel flex-devel automake libtool bison libuv-devel flex

或者直接跳过,在安装过程中如果报错缺什么再返回来安装。下面是部分依赖缺乏时的解决:

下载&编译&安装
  cd /usr/src
  git clone https://github.com/sipcapture/captagent.git captagent
  cd captagent
  ./build.sh
  ./configure
  make && make install

默认安装目录:/usr/local/captagent

配置

配置文件在以下三个目录中:
/usr/local/captagent/etc/captagent
/usr/local/captagent/etc/captagent/captureplans
/usr/local/captagent/lib/captagent/modules
下面是基本配置:

  1. 首先去captagent.xml文件中检查一下上面三个配置文件的目录是否准确;
  2. captureplans/sip_capture_plan.cfg中,确保if(sip_has_sdp())代码块没有被注释:
    在这里插入图片描述
  3. socket_pcap.xml中,确保RTCP的enable为true:
    在这里插入图片描述
  4. transport_hep.xml中配置Capture Server的地址和端口:
    在这里插入图片描述
  5. 配置服务并启动(CentOS7)
    captagent.service
    captagent.sysconfig
    这两个文件放到安装目录/usr/local/captagent/中,然后:
cp /usr/local/captagent/captagent.service /etc/systemd/system/
cp /usr/local/captagent/captagent.sysconfig /etc/sysconfig/captagent
systemctl daemon-reload
systemctl enable captagent
systemctl start captagent

tips:如果想看看启动有什么异常,可以前台启动captagent:

/usr/local/captagent/sbin/captagent -n
  1. 记得关掉fs的capture功能:fs_cli客户端中输入 sofia global capture off。否则fs和captagent同会重复捕获sip消息。

现在在homer-app中多了一个QoS标签:
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值