apt-get install unixodbc unixodbc-dev odbcinst
 apt-get install odbc-postgresql
[fscdr]
Description         = PostgreSQL
Driver              = PostgreSQL Unicode
Trace               = No
TraceFile           = /tmp/psqlodbc.log
Database            = DATABASE
Servername          = 127.0.0.1
UserName            = USER
Password            = PASS
Port                = 5432
ReadOnly            = No
RowVersioning       = No
ShowSystemTables    = No
ShowOidColumn       = No
FakeOidIndex        = No
ConnSettings        =

install mod_odbc_cdr

odbc_cdr.conf.xml

<configuration name="odbc_cdr.conf" description="ODBC CDR Configuration">
    <settings>
        <param name="odbc-dsn" value="odbc://fscdr" />
        <!-- global value can be "a-leg", "b-leg", "both" (default is "both") -->
        <param name="log-leg" value="both" />
        <!-- value can be "always", "never", "on-db-fail" -->
        <param name="write-csv" value="never" />
        <param name="debug-sql" value="true" />
    </settings>
    <tables>
        <!-- only a-legs will be inserted into this table -->
        <table name="cdr" log-leg="a-leg">
            <field name="local_ip_v4" chan-var-name="domain" />
            <field name="caller_id_name" chan-var-name="caller_id_name" />
            <field name="caller_id_number" chan-var-name="caller_id_number" />
            <field name="destination_number" chan-var-name="destination_number" />
            <field name="context" chan-var-name="context" />
            <field name="start_stamp" chan-var-name="start_stamp" />
            <field name="answer_stamp" chan-var-name="answer_stamp" />
            <field name="end_stamp" chan-var-name="end_stamp" />
            <field name="duration" chan-var-name="duration" />
            <field name="billsec" chan-var-name="billsec" />
            <field name="hangup_cause" chan-var-name="hangup_cause" />
            <field name="uuid" chan-var-name="uuid" />
            <field name="bleg_uuid" chan-var-name="bleg_uuid" />
            <field name="accountcode" chan-var-name="accountcode" />
            <field name="read_codec" chan-var-name="read_codec" />
            <field name="write_codec" chan-var-name="write_codec" />
            <field name="sip_hangup_disposition" chan-var-name="sip_hangup_disposition" />
            <field name="ani" chan-var-name="ani" />
        </table>
    </tables>
</configuration>

postgres table cdr

CREATE TABLE cdr (
    id                        serial PRIMARY KEY,
    local_ip_v4               inet NOT NULL,
    caller_id_name            VARCHAR,
    caller_id_number          VARCHAR,
    destination_number        VARCHAR NOT NULL,
    context                   VARCHAR NOT NULL,
    start_stamp               TIMESTAMP WITH TIME zone NOT NULL,
    answer_stamp              TIMESTAMP WITH TIME zone,
    end_stamp                 TIMESTAMP WITH TIME zone NOT NULL,
    duration                  INT NOT NULL,
    billsec                   INT NOT NULL,
    hangup_cause              VARCHAR NOT NULL,
    uuid                      uuid NOT NULL,
    bleg_uuid                 uuid,
    accountcode               VARCHAR,
    read_codec                VARCHAR,
    write_codec               VARCHAR,
    sip_hangup_disposition    VARCHAR,
    ani                       VARCHAR
);

Доп инфо https://asterisk-pbx.ru/wiki/freeswitch/db/fs_cdr_pg_csv

Только авторизованные участники могут оставлять комментарии.
  • freeswitch/db/fs_cdr_odbc_postgres.txt
  • Последние изменения: 2019/04/24