siremis:install33x:accounting

Siremis v3.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:
#!define WITH_MYSQL
#!define WITH_ACCDB
  • set db_extra parameter (it is the same as the one in default kamailio.cfg for v3.3.x):
modparam("acc", "db_extra",
    "src_user=$fU;src_domain=$fd;src_ip=$si;"
    "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")

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:

siremis/modules/ser/mod.install.siremis.sql

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.

# -- 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://openser:openserrw@localhost/openser")
 
 
 
# ======================================================
# Populate CDRs Table of Siremis
# ======================================================
route[CDRS] {
	sql_query("cb","call kamailio_cdrs()","rb");
	sql_query("cb","call kamailio_rating('default')","rb");
 
}

100%


Copyright 2010-2020 Asipto.com