Skip to content

areski/freeswitch_realtime

Repository files navigation

Collect Realtime information from FreeSWITCH to Influxdb & PostgreSQL Build Status

Collect Realtime information from FreeSWITCH to InfluxDB & PostgreSQL.

Channels information are pushed in the form of:

%ChannelSeries{fields: %ChannelSeries.Fields{value: 1},
tags: %ChannelSeries.Tags{campaign_id: 1, host: "127.0.0.1"}, timestamp: nil}

If you wish to use this with an other project you might want to remove campaign_id which is specific to Newfies-Dialer.

Usage Dev

Run dev:

MIX_ENV=dev iex -S mix

Check outdated deps:

mix hex.outdated

Usage Test

Run test.watch:

MIX_ENV=dev mix test.watch

Usage Prod

Compile and release:

MIX_ENV=prod mix compile
# MIX_ENV=prod mix release.init
MIX_ENV=prod mix release --verbose

Installation

Create directory for logs:

mkdir /var/log/freeswitch_realtime

Add host in your /etc/hosts eg:

127.0.0.1     influxdb-host

Compile & Build Release

Firstly, edit version in mix.exs.

Then compile:

MIX_ENV=prod mix compile

Finally, build the release:

MIX_ENV=prod mix release

Build with Docker for Debian 8 (Jessie)

Create releases directory & give permissions:

mkdir releases
chmod 0777 releases

Create the new docker image and then create the releases:

docker build --tag=build-elixir-jessie -f docker/Dockerfile.build.elixir .
docker run -e "MIX_ENV=prod" -v $PWD/releases:/app/releases build-elixir-jessie mix release --verbose --env=prod

Run tests

You will need to install inotify-tools to use mix test.watch. mix test.watch will automatically run your Elixir project's tests each time you save a file (https://github.com/lpil/mix-test.watch)

You will need inotify-tools installed.

Code linter

We use Credo as colinter

mix credo

Start on reboot

Add freeswitch_realtime to systemd on Debian 8.x:

cp freeswitch_realtime.service /lib/systemd/system/freeswitch_realtime.service
systemctl enable freeswitch_realtime.service
systemctl daemon-reload
systemctl restart freeswitch_realtime.service

Troubleshooting

Ensure InfluxDB is working properly.

Create DB:

curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"

Write to serie cpu_load_short:

curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'

Read data:

curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=mydb" --data-urlencode "q=SELECT \"value\" FROM \"cpu_load_short\" WHERE \"region\"='us-west'"

With to database newfiesdialer serie freeswitch_channels_cpg_total:

curl -i -XPOST 'http://localhost:8086/write?db=newfiesdialer' --data-binary 'freeswitch_channels_cpg_total,host=37.139.13.157,campaign_id=1,leg_type=1 value=0.64 1434055562000000000'

Read from serie freeswitch_channels_cpg_total:

curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=newfiesdialer" --data-urlencode "q=SELECT \"value\" FROM \"freeswitch_channels_cpg_total\""

About

Push FreeSWITCH Realtime info to InfluxDB & PostgreSQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages