siremis:install53x:accounting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

siremis:install53x:accounting [2020/02/26 14:28] (current)
admin created
Line 1: Line 1:
 +====== Siremis v5.3.x - Setup Accounting Services ======
  
 +===== Accounting Panel =====
 +
 +This view maps on the records stored by Kamailio's **acc** module -- the event-based accounting, storing the START and STOP records for each call.
 +
 +You can see these records from **Accounting Services => Accounting List** and **Accounting Services => Missed Calls List**.
 +
 +===== Config file =====
 +
 +Changes in file kamailio.cfg
 +  * make sure acc is configured with MySQL support
 +    * in default kamailio.cfg add after the first line:
 +<code>
 +#!define WITH_MYSQL
 +#!define WITH_ACCDB
 +</code>
 +  * set db_extra parameter (it is the same as the one in default kamailio.cfg for v5.1.x):
 +<code>
 +modparam("acc", "db_extra",
 +    "src_user=$fU;src_domain=$fd;src_ip=$si;"
 +    "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
 +</code>
 +
 +===== Database =====
 +
 +Kamailio database structure and stored procedure were created by Siremis Web Installation Wizard by checking "Update SIP Database" option in Step 2. These DB operations consisted of:
 +
 +  * drop existing acc and missed_calls tables
 +  * create acc and missed_calls tables with the new structure required to generate the CDRs
 +  * create kamailio_cdrs() stored procedure
 +  * create kamailio_rating() stored procedure
 +
 +If you want to see the SQL commands used to do above DB operations, see the file:
 +
 +<code>
 +siremis/modules/ser/mod.install.siremis.sql
 +</code>
 +
 +===== Generate CDRs =====
 +
 +The stored procedure for generating CDRs was created during installation process. It is named **kamailio_cdrs()**. You have to execute it periodically from a cron.d job or you can user **rtimer** and **sqlops** modules to execute it periodically from Kamailio configuration file.
 +
 +You can see CDRs in Siremis panel: **Accounting Services => CDR List** 
 +
 +===== Rating CDRs =====
 +
 +The stored procedure for rating CDRs was created during installation process. It is named **kamailio_rating()**. It takes one parameter, rgroup, which corresponds to **rate_group** column in billing_rates table.
 +
 +The rules for rating the calls (billing) have to be added in table **billing_rates**. The rating engine uses the longest prefix matching to select the **rate_unit** and the **time_unit** to bill the CDRs. Each rating rule is composed from:
 +
 +  * **rate_group** - used to group the billing rules -- it has to be given as parameter to **kamailio_rating()** store procedure
 +  * **prefix** - the prefix to match the **dst_user** in **cdrs** table
 +  * **time_unit** - time unit in seconds to bill the cdrs
 +  * **rate_unit** - the cost per **time_unit** - there is no currency associated with it, i has to be integer, so based on your needs, you can consider setting it as subdivisions (e.g., cents)
 +
 +Also, like for CDRs generation, you have to execute it periodically -- again from a cron.d job or you can user **rtimer** and **sqlops** modules to execute it periodically from Kamailio configuration file.
 +
 +===== kamailio.cfg for generating and rating CDRs =====
 +
 +Here are the kamailio.cfg snippets to generate and rate CDRs periodically from a running Kamailio instance.
 +
 +<code c>
 +
 +# -- for siremis CDRs --------------
 +loadmodule "rtimer.so"
 +loadmodule "sqlops.so"
 +
 +modparam("rtimer", "timer", "name=cdr;interval=300;mode=1;")
 +modparam("rtimer", "exec", "timer=cdr;route=CDRS")
 +modparam("sqlops", "sqlcon", "cb=>mysql://kamailio:kamailiorw@localhost/kamailio")
 +
 +
 +
 +# ======================================================
 +# Populate CDRs Table of Siremis
 +# ======================================================
 +route[CDRS] {
 + sql_query("cb","call kamailio_cdrs()","rb");
 + sql_query("cb","call kamailio_rating('default')","rb");
 +
 +}
 +</code>
 +
 +{{tag>siremis kamailio}}

100%


Copyright 2010-2020 Asipto.com