This shows you the differences between two versions of the page.
— | siremis:install53x:accounting [2020/02/26 13:28] (current) – created admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Siremis v5.3.x - Setup Accounting Services ====== | ||
+ | ===== Accounting Panel ===== | ||
+ | |||
+ | This view maps on the records stored by Kamailio' | ||
+ | |||
+ | 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: | ||
+ | < | ||
+ | #!define WITH_MYSQL | ||
+ | #!define WITH_ACCDB | ||
+ | </ | ||
+ | * set db_extra parameter (it is the same as the one in default kamailio.cfg for v5.1.x): | ||
+ | < | ||
+ | modparam(" | ||
+ | " | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | ===== Database ===== | ||
+ | |||
+ | Kamailio database structure and stored procedure were created by Siremis Web Installation Wizard by checking " | ||
+ | |||
+ | * 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: | ||
+ | |||
+ | < | ||
+ | siremis/ | ||
+ | </ | ||
+ | |||
+ | ===== 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 " | ||
+ | loadmodule " | ||
+ | |||
+ | modparam(" | ||
+ | modparam(" | ||
+ | modparam(" | ||
+ | |||
+ | |||
+ | |||
+ | # ====================================================== | ||
+ | # Populate CDRs Table of Siremis | ||
+ | # ====================================================== | ||
+ | route[CDRS] { | ||
+ | sql_query(" | ||
+ | sql_query(" | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | {{tag> |