Updated documentation

This commit is contained in:
Trial97
2020-07-30 12:11:21 +03:00
committed by Dan Christian Bogos
parent 12e3d6b182
commit b2004e3a6e
56 changed files with 65 additions and 3742 deletions

View File

@@ -8,7 +8,7 @@
# re-generating the scenario with different options.#
#
# Please refer to the Core CookBook at:
# http://www.opensips.org/Resources/DocsCookbooks
# https://opensips.org/Resources/DocsCookbooks
# for a explanation of possible statements, functions and parameters.
#

View File

@@ -8,7 +8,7 @@
# re-generating the scenario with different options.#
#
# Please refer to the Core CookBook at:
# http://www.opensips.org/Resources/DocsCookbooks
# https://opensips.org/Resources/DocsCookbooks
# for a explanation of possible statements, functions and parameters.
#

View File

@@ -1,4 +1,5 @@
.. _Agents:
.. _agents:
Agents
======

View File

@@ -1,7 +1,9 @@
.. _attributes:
AttributeS
==========
**AttributeS** is a standalone subsystem within **CGRateS** and it is the equivalent of a key-value store. It is accessed via :ref:`CGRateS RPC APIs<remote-management>`.
**AttributeS** is a standalone subsystem within **CGRateS** and it is the equivalent of a key-value store. It is accessed via `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_.
As most of the other subsystems, it is performance oriented, stored inside *DataDB* but cached inside the *cgr-engine* process.
Caching can be done dynamically/on-demand or at start-time/precached and it is configurable within *cache* section in the :ref:`JSON configuration <configuration>`.
@@ -108,7 +110,7 @@ Type
Will compute the exponent of the first field in the *Value*.
Value
The value which will be set for *Path*. It can be a list of :ref:`RSRParsers` capturing even from multiple sources in the same event. If the *Value* is *\*remove* the field with *Path* will be removed from *Event*
The value which will be set for *Path*. It can be a list of RSRParsers capturing even from multiple sources in the same event. If the *Value* is *\*remove* the field with *Path* will be removed from *Event*
Inline Attribute

View File

@@ -1,3 +1,5 @@
.. _caches:
CacheS
======

View File

@@ -1,86 +0,0 @@
CDR Client (cdrc)
=================
It's role is to gather offline CDRs and post them to CDR Server(CDRS) component.
Part of the *cgr-engine*, can be started on a remote server as standalone component.
Controlled within *cdrc* section of the configuration file.
Has two modes of operation:
- Automated: CDR file processing is triggered on file creation/move.
- Periodic: CDR file processing will be triggered at configured time interval (delay/sleep between processes) and it will be performed on all files present in the folder (IN) at run time.
Principles behind functionality:
- Monitor/process a CDR folder (IN) as outlined above.
- For every file processed, extract the information based on configuration and post it via configured mechanism to CDRS.
- The fields extracted out of each CDR row are the same ones depicted in the CDRS documentation (following primary and extra fields concept).
- Once the file processing completes, move it in it's original format in another folder (OUT) in order to avoid re-processing. Here it's worth mentioning the auto-detection of duplicated CDRs at server side based on accid and host fields.
- Advanced configuration like forking a number of simultaneous client instances monitoring different folders possible through the use of *.xml* configuration.
Import Templates
----------------
To specifiy custom imports (for various sources) one can specify *Import Templates*. These are definable within both *.cfg* as well as *.xml* advanced configuration files.
For increased flexibility the Import Template can be defined using CGR-RSR fields capturing both ReGexp as well as static rules. The static values will be way faster in processing but limited in functionality.
CGR-RSR Regexp Rule
~~~~~~~~~~~~~~~~~~~
Format:
::
~path:s/regexp_search_and_capture_rule/output_teplate/
Example of usage:
::
Input CDR field:
{
"account": "First-Account123"
}
Capture Rule:
~account:s/^*+(Account123)$/$1-processed/
Result after processing:
{
"account": "Account123-processed"
}
CGR-RSR Static Rule
~~~~~~~~~~~~~~~~~~~
Format:
::
^path:static_value
Example of usage:
::
Input CDR field:
{
"account": "First-Account123"
}
Capture Rule:
^account:MasterAccount
Result after processing:
{
"account": "MasterAccount"
}
CDR Formats supported:
CDR .CSV
--------
Most widely used format by Telecom Switches.
Light to read and generic to process.
CDRC should be able to process in this way any .csv CDR, independent of the Telecom Switch generating them. Incompatibilities here can come out of answer time and duration formats which can vary between CDR writer implementations.
As answer time we support a number of formats already - rfc3339, SQL/MySQL, unix timestamp. As duration we support nanoseconds granularity in our code. Time unit can be specified (eg: ms, s, m, h), or if missing, will default to nanoseconds.
In case of *.csv* files the Import Template will contain indexes for the possition where primary fields are located (0 representing the first field) and fieldname/position format for extra fields which need not only to be extracted by row index but also to be named since .csv format does not save field names/labels. CDRC uses the following convention for extra fields in the configuration: *<label_extrafield_1>:<index_extrafield_1>[...,<label_extrafield_n>:<index_extrafield_n>]...*.

View File

@@ -10,7 +10,7 @@ CDRe
====
**CDRe** is an extension of :ref:`CDRs`, responsible for exporting the *CDR* events processed by :ref:`CDRs`. It is accessed via :ref:`CGRateS RPC APIs<remote-management>` and configured within *cdre* section inside :ref:`JSON configuration <configuration>`.
**CDRe** is an extension of :ref:`CDRs`, responsible for exporting the *CDR* events processed by :ref:`CDRs`. It is accessed via `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_ and configured within *cdre* section inside :ref:`JSON configuration <configuration>`.
Export types
@@ -32,7 +32,7 @@ You can control the templates which are to be executed via the filters which are
Offline exports
^^^^^^^^^^^^^^^
Are exports which are triggered via :ref:`CGRateS RPC APIs<remote-management>` and they have as data source the CDRs stored within *StorDB*.
Are exports which are triggered via `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_ and they have as data source the CDRs stored within *StorDB*.
@@ -56,16 +56,16 @@ export_format
Exports into a fixed width file format.
**\*http_post**
Will post the CDR to a HTTP server. The export content will be a HTTP form encoded representation of the :ref:`internal CDR object<CDR>`.
Will post the CDR to a HTTP server. The export content will be a HTTP form encoded representation of the `internal CDR object <https://godoc.org/github.com/cgrates/cgrates/engine#CDR>`_.
**\*http_json_cdr**
Will post the CDR to a HTTP server. The export content will be a JSON serialized representation of the :ref:`internal CDR object<CDR>`.
Will post the CDR to a HTTP server. The export content will be a JSON serialized representation of the `internal CDR object <https://godoc.org/github.com/cgrates/cgrates/engine#CDR>`_.
**\*http_json_map**
Will post the CDR to a HTTP server. The export content will be a JSON serialized hmap with fields defined within the *fields* section of the template.
**\*amqp_json_cdr**
Will post the CDR to an AMQP_ queue. The export content will be a JSON serialized representation of the :ref:`internal CDR object<CDR>`. Uses AMQP_ protocol version 0.9.1.
Will post the CDR to an AMQP_ queue. The export content will be a JSON serialized representation of the `internal CDR object <https://godoc.org/github.com/cgrates/cgrates/engine#CDR>`_. Uses AMQP_ protocol version 0.9.1.
**\*amqp_json_map**
Will post the CDR to an AMQP_ queue. The export content will be a JSON serialized hmap with fields defined within the *fields* section of the template. Uses AMQP_ protocol version 1.0.

View File

@@ -1,122 +0,0 @@
CDR Exporter
============
Component to retrieve rated CDRs from internal CDRs database.
Although nowadays it is custom to read a storage/database with tools, we do not recommend doing it so due to possibility that reads can slow down complete rating system. For this purpose we have created exporter plugins which are meant to work in tight relationship with CGRateS internal components in order to best optimize performance and avoid system locks.
Export Templates
----------------
For advanced needs CGRateS Export Templates are configurable via *.cfg*, *.xml* as well as directly within RPC call requesting the export to be performed.
Inside each Export Template one can either specify simple CDR field ids or use CGR-RSR fields capturing both Regexp as well as static rules.
CGR-RSR Regexp Rule
~~~~~~~~~~~~~~~~~~~
Format:
::
~path:s/regexp_search_and_capture_rule/output_teplate/
Example of usage:
::
Input CDR field:
{
"account": "First-Account123"
}
Capture Rule:
~account:s/^*+(Account123)$/$1-processed/
Result after processing:
{
"account": "Account123-processed"
}
CGR-RSR Static Rule
~~~~~~~~~~~~~~~~~~~
Format:
::
^path:static_value
Example of usage:
::
Input CDR field:
{
"account": "First-Account123"
}
Capture Rule:
^account:MasterAccount
Result after processing:
{
"account": "MasterAccount"
}
Export interfaces implemented:
CGR-CSV
-------
Simplest way to export CDRs in a format internally defined (with parts like *CDRExtraFields* configurable in main configuration file).
Principles behind exports:
- Exports are to be manually requested (although automated is planned for the future through the used of built-in scheduled actions) via exposed JSON-RPC api. Example of api call from python call provided as sample script:
::
rpc.call("APIerSv1.ExportCsvCdrs",{"TimeStart":"1383823746","TimeEnd":"1383833746"} )
- On each export call there will be a .csv format file generated using configured separator. Location of the export folder is definable inside *cgrates.cfg*.
- File name of the export will appear like: *cdrs_$(timestamp).csv* where $(timestamp) will be replaced by unix timestamp of the server running the export process or requested via API call.
- Each exported file will have as content all the CDRs inside time interval defined in the API call. Both TimeStart and TimeEnd are optional, hence being able to obtain a full export of the available CDRs with one API call.
- To be noted here that CGRateS does not keep anywhere a history of exports, hence it is the responsibility of the system administrator to make sure that his exports are not doubled.
- If not otherwise defined, each line within the exported file will follow an internally predefined template:
cgrid,mediation_runid,tor,accid,reqtype,direction,tenant,category,account,subject,destination,setup_time,answer_time,usage,cost
::
$(cgrid),$(mediation_runid),$(tor),$(accid),$(reqtype),$(direction),$(direction),$(tenant),$(category),$(account),$(subject),$(destination),$(setup_time),$(answer_time),$(usage),$(cost)
The significance of the fields exported:
- tor: type of record, meta-field, should map to one of the TORs hardcoded inside the server <*voice|*data|*sms>
- accid: represents the unique accounting id given by the telecom switch generating the CDR
- cdrhost: represents the IP address of the host generating the CDR (automatically populated by the server)
- cdrsource: formally identifies the source of the CDR (free form field)
- reqtype: matching the supported request types by the **CGRateS**, accepted values are hardcoded in the server <prepaid|postpaid|pseudoprepaid|rated>.
- direction: matching the supported direction identifiers of the CGRateS <*out>
- tenant: tenant whom this record belongs
- category: free-form filter for this record, matching the category defined in rating profiles.
- account: account id (accounting subsystem) the record should be attached to
- subject: rating subject (rating subsystem) this record should be attached to
- destination: destination to be charged
- setup_time: set-up time of the event. Supported formats: datetime RFC3339 compatible, SQL datetime (eg: MySQL), unix timestamp.
- answer_time: answer time of the event. Supported formats: datetime RFC3339 compatible, SQL datetime (eg: MySQL), unix timestamp.
- usage: event usage information (eg: in case of tor=*voice this will represent the total duration of a call)
- extra_cdr_fields:
- selected list of cdr_extra fields via *cgrates.cfg* configuration or
- alphabetical order of the cdr extra fields stored in cdr_extra table
Sample CDR export file content which was made available at path: */var/log/cgrates/cdr/out/cgr/csv/cdrs_1384104724.csv*
::
dbafe9c8614c785a65aabd116dd3959c3c56f7f6,default,*voice,dsafdsaf,rated,*out,cgrates.org,call,1001,1001,1002,2013-11-07T08:42:25Z,2013-11-07T08:42:26Z,10000000000,1.0100
CGR-FWV
-------
Fixed width form of export CDR. Advanced template configuration available via *.xml* configuration file.
Hybrid CSV-FWV
--------------
For advanced needs **CGRateS** supports exporting the CDRs as combination between *.csv* and *.fwv* formats.

View File

@@ -4,7 +4,7 @@ CDRs
====
**CDRs** is a standalone subsystem within **CGRateS** responsible to process *CDR* events. It is accessed via :ref:`CGRateS RPC APIs<remote-management>` or separate *HTTP handlers* configured within *http* section inside :ref:`JSON configuration <configuration>`.
**CDRs** is a standalone subsystem within **CGRateS** responsible to process *CDR* events. It is accessed via `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_ or separate *HTTP handlers* configured within *http* section inside :ref:`JSON configuration <configuration>`.
Due to multiple interfaces exposed, the **CDRs** is designed to function as centralized server for *CDRs* received from various sources. Examples of such sources are:
*\*real-time events* from interfaces like *Diameter*, *Radius*, *Asterisk*, *FreeSWITCH*, *Kamailio*, *OpenSIPS*

View File

@@ -1,125 +0,0 @@
CDR Server
==========
An important component of every rating system is represented by the CDR Server. CGRateS includes an out of the box CDR Server component, controlable in the configuration file and supporting multiple interfaces for CDR feeds. This component makes the CDRs real-time accessible (influenced by the time of receiving them) to CGRateS subsystems.
Following interfaces are supported:
CDR-CGR
-------
Available as handler within http server.
To feed CDRs in via this interface, one must use url of the form: <http://$ip_configured:$port_configured/cdr_http>.
The CDR fields are received via http form (although for simplicity we support inserting them within query parameters as well) and are expected to be urlencoded in order to transport special characters reliably. All fields are expected by CGRateS as string, particular conversions being done on processing each CDR.
The fields received are split into two different categories based on CGRateS interest in them:
Primary fields: the fields which CGRateS needs for it's own operations and are stored into cdrs_primary table of storDb.
- ToR: type of record, meta-field, should map to one of the TORs hardcoded inside the server <*voice|*data|*sms>
- OriginID: represents the unique accounting id given by the telecom switch generating the CDR
- OrderID: Stor order id used as export order id
- OriginHost: represents the IP address of the host generating the CDR (automatically populated by the server)
- Source: formally identifies the source of the CDR (free form field)
- RequestType: matching the supported request types by the **CGRateS**, accepted values are hardcoded in the server <prepaid|postpaid|pseudoprepaid|rated>.
- Category: free-form filter for this record, matching the category defined in rating profiles.
- Tenant: tenant whom this record belongs
- Account: account id (accounting subsystem) the record should be attached to
- Subject: rating subject (rating subsystem) this record should be attached to
- Destination: destination to be charged
- SetupTime: set-up time of the event. Supported formats: datetime RFC3339 compatible, SQL datetime (eg: MySQL), unix timestamp.
- AnswerTime: answer time of the event. Supported formats: datetime RFC3339 compatible, SQL datetime (eg: MySQL), unix timestamp.
- Usage: event usage information (eg: in case of tor=*voice this will represent the total duration of a call)
- CostSource: The source of this cost
- Rated: Mark the CDR as rated so we do not process it during rating
Extra fields: any field coming in via the http request and not a member of primary fields list. These fields are stored as json encoded into *cdrs_extra* table of storDb.
Example of sample CDR generated simply using curl:
::
curl --data "ToR=*voice \
&Source=curl_cdr \
&OrderID=abcde \
&OriginHost=192.168.1.2 \
&Source=sbc1 \
&OriginID=qwerty3234567 \
&ToR=*voice \
&RequestType=*raw \
&Tenant=192.168.56.66 \
&Category=call \
&Account=1004 \
&Subject=1004 \
&Destination=%2B4986517174963 \
&SetupTime=2018-05-21T12:32:50Z \
&AnswerTime=2018-05-21T12:32:56Z \
&Usage=306 \
&CostSource=*cdrs" http://127.0.0.1:2080/cdr_http
CDR-FS_JSON
-----------
Available as handler within http server, it implements the mechanism to store CDRs received from FreeSWITCH mod_json_cdr.
This interface is available at url: <http://$ip_configured:$port_configured/freeswitch_json>.
This handler has a different implementation logic than the previous CDR-CGR, filtering fields received in the CDR from FreeSWITCH based on predefined configuration.
The mechanism of extracting CDR information out of JSON encoded CDR received from FreeSWITCH is the following:
- When receiving the CDR from FreeSWITCH, CGRateS will extract the content of ''variables'' object.
- Content of the ''variables'' will be filtered out and the following information will be stored into an internal CDR object:
- Fields used by CGRateS in primary mediation, known as primary fields. These are:
- uuid: internally generated uuid by FreeSWITCH for the call
- sip_local_network_addr: IP address of the FreeSWITCH box generating the CDR
- sip_call_id: call id out of SIP protocol
- cgr_reqtype: request type as understood by the CGRateS
- cgr_category: call category (optional)
- cgr_tenant: tenant this call belongs to (optional)
- cgr_account: account id in CGRateS (optional)
- cgr_subject: rating subject in CGRateS (optional)
- cgr_destination: destination being rated (optional)
- user_name: username as seen by FreeSWITCH (considered if cgr_subject or cgr_account not present)
- dialed_extension: destination number considered if cgr_destination is missing
- Fields stored at request in cdr_extra and definable in configuration file under *extra_fields*.
- Once the content will be filtered, the real CDR object will be processed, stored into storDb under *cdrs_primary* and *cdrs_extra* tables and, if configured, it will be passed further for mediation.
CDR-RPC
-------
Available as RPC handler on top of CGR APIs exposed (in-process as well as GOB-RPC and JSON-RPC). This interface is used for example by CGR-SM component capturing the CDRs over event interface (eg: OpenSIPS or FreeSWITCH-ZeroConfig scenario)
The RPC function signature looks like this:
::
CDRSV1.ProcessCdr(cdr *utils.StoredCdr, reply *string) error
The simplified StoredCdr object is represented by following:
::
type StoredCdr struct {
CgrId string
OrderId int64 // Stor order id used as export order id
ToR string // type of record, meta-field, should map to one of the TORs hardcoded inside the server <*voice|*data|*sms>
AccId string // represents the unique accounting id given by the telecom switch generating the CDR
CdrHost string // represents the IP address of the host generating the CDR (automatically populated by the server)
CdrSource string // formally identifies the source of the CDR (free form field)
ReqType string // matching the supported request types by the **CGRateS**, accepted values are hardcoded in the server <prepaid|postpaid|pseudoprepaid|rated>.
Direction string // matching the supported direction identifiers of the CGRateS <*out>
Tenant string // tenant whom this record belongs
Category string // free-form filter for this record, matching the category defined in rating profiles.
Account string // account id (accounting subsystem) the record should be attached to
Subject string // rating subject (rating subsystem) this record should be attached to
Destination string // destination to be charged
SetupTime time.Time // set-up time of the event. Supported formats: datetime RFC3339 compatible, SQL datetime (eg: MySQL), unix timestamp.
AnswerTime time.Time // answer time of the event. Supported formats: datetime RFC3339 compatible, SQL datetime (eg: MySQL), unix timestamp.
Usage time.Duration // event usage information (eg: in case of tor=*voice this will represent the total duration of a call)
ExtraFields map[string]string // Extra fields to be stored in CDR
}

View File

@@ -1,174 +0,0 @@
.. _cdrstats-main:
CDR Stats Server
================
Collects CDRs from various sources (eg: CGR-CDRS, CGR-Mediator, CGR-SM,
third-party CDR source via RPC) and builds real-time stats based on them. Each
StatsQueue has attached *ActionTriggers* with monitoring and actions
capabilities.
Principles of functionality:
- Standalone component (can be started individually on remote hardware, isolated form other CGRateS compoenents).
- Performance oriented. Should be able to process tens of thousands of CDRs per second.
- Cache driven technology. But SaveInterval can be set to store this information
on redis.
- Stats are build within *StatsQueues* a CDR Stats Server being able to support
unlimited number of StatsQueues. Each CDR will be passed to all of StatsQueues
available and will be processed by individual StatsQueue based on configuration.
- Stats will be build inside Metrics (eg: ASR, ACD, ACC, TCC) and attached to specific StatsQueue.
- Each StatsQueue will have attached one *ActionTriggers* profile which will
monitor Metrics values and react on thresholds reached (unlimited number of
thresholds and reactions configurable).
- CDRs are processed by StatsQueues if they pass CDR field filters.
- CDRs are auto-removed from StatsQueues in a *fifo* manner if the QueueLength
is reached or if they do not longer fit within TimeWindow defined.
Configuration
-------------
Individual StatsQueue configurations are loaded inside TariffPlan defitions, one
configuration object is internally represented as:
::
type CdrStats struct {
Id string // Config id, unique per config instance
QueueLength int // Number of items in the stats buffer
TimeWindow time.Duration // Will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow
SaveInterval time.Duration // Interval to store the info into database
Metrics []string // ASR, ACD, ACC, TCC, TCD, PDD
SetupInterval []time.Time // CDRFieldFilter on SetupInterval, 2 or less items (>= start interval,< stop_interval)
ToR []string // CDRFieldFilter on TORs
CdrHost []string // CDRFieldFilter on CdrHosts
CdrSource []string // CDRFieldFilter on CdrSources
ReqType []string // CDRFieldFilter on ReqTypes
Direction []string // CDRFieldFilter on Directions
Tenant []string // CDRFieldFilter on Tenants
Category []string // CDRFieldFilter on Categories
Account []string // CDRFieldFilter on Accounts
Subject []string // CDRFieldFilter on Subjects
DestinationPrefix []string // CDRFieldFilter on DestinationPrefixes
UsageInterval []time.Duration // CDRFieldFilter on UsageInterval, 2 or less items (>= Usage, <Usage)
PddInterval []time.Duration // CDRFieldFilter on PddInterval, 2 or less items (>= Pdd, <Pdd)
Supplier []string // CDRFieldFilter on Suppliers
DisconnectCause []string // Filter on DisconnectCause
MediationRunIds []string // CDRFieldFilter on MediationRunIds
RatedAccount []string // CDRFieldFilter on RatedAccounts
RatedSubject []string // CDRFieldFilter on RatedSubjects
CostInterval []float64 // CDRFieldFilter on CostInterval, 2 or less items, (>=Cost, <Cost)
Triggers ActionTriggerPriotityList
}
.. _cdrstats-metrics:
Metrics Types
-------------
- ACC *(Average Call Cost)*: Queue with the average call cost
- ACD *(Average Call Duration)*: Queue with the average call duration
- ASR *(Answer-Seizure Ratio)*: Queue with the answer ratio
- PDD *(Post Dial Delay )*: Queue with the average Post Dial Delay in seconds
- TCC *(Total Call Cost)*: Queue with the Total cost for the time frame.
- TCD *(Total Call Duration)*: Queue with the total call duration for the
time frame
ExternalQueries
---------------
The Metrics calculated are available to be real-time queried via RPC methods.
To facilitate interaction there are four commands built in the provided *cgr-console* tool:
- *cdrstats_queueids*: returns the queue ids processing CDR Stats.
- *cdrstats_metrics*: returns metrics calculated within specific CDRStatsQueue.
- *cdrstats_reload*: reloads the CdrStats configurations out of DataDb.
- *cdrstats_reset*: resets calculated metrics for one specific or all StatsQueues.
Example use
-----------
When you work with balance maybe you want to keep a eye in your users, so you
can add a new queue for the last 5 hours to check that your customer it's not
hacked, this is an example:
**CDR stats:**
.. code-block:: javascript
"result":{
"CdrStats": [
{
"Accounts": "my_account",
"ActionTriggers": "FRAUD_CHECK",
"Categories": "",
"CdrHosts": "",
"CdrSources": "",
"CostInterval": "",
"DestinationPrefixes": "",
"Directions": "",
"DisconnectCauses": "",
"MediationRunIds": "",
"Metrics": "TCC",
"PddInterval": "",
"QueueLength": "0",
"RatedAccounts": "",
"RatedSubjects": "",
"ReqTypes": "",
"SaveInterval": "15s",
"SetupInterval": "",
"Subjects": "",
"Suppliers": "",
"TORs": "",
"Tenants": "foehn",
"TimeWindow": "5h",
"UsageInterval": ""
}
],
"CdrStatsId": "FRAUD_ACCOUNT",
"TPid": "test"
}
**Action Trigger:**
.. code-block:: javascript
"result": {
"ActionTriggers": [
{
"ActionsId": "LOG_WARNING",
"BalanceCategory": "",
"BalanceDestinationIds": "",
"BalanceDirection": "",
"BalanceExpirationDate": "",
"BalanceId": "",
"BalanceRatingSubject": "",
"BalanceSharedGroup": "",
"BalanceTimingTags": "",
"BalanceType": "",
"BalanceWeight": 0,
"Id": "",
"MinQueuedItems": 0,
"MinSleep": "3h",
"Recurrent": true,
"ThresholdType": "\\*max_tcc",
"ThresholdValue": 150,
"Weight": 10
}
],
"ActionTriggersId": "FRAUD_CHECK",
"TPid": "test"
}
Using *cgr-console* you can check the status of the queue anytime:
.. code-block:: bash
cgr-console 'cdrstats_metrics StatsQueueId="FRAUD_ACCOUNT"'

View File

@@ -1,9 +1,11 @@
.. _chargers:
ChargerS
========
**ChargerS** is a **CGRateS** subsystem designed to produce billing runs via *DerivedCharging* mechanism.
It works as standalone component of **CGRateS**, accessible via :ref:`CGRateS RPC<remote-management>` via a rich set of *APIs*. As input **ChargerS** is capable of receiving generic events (hashmaps) with dynamic types for fields.
It works as standalone component of **CGRateS**, accessible via `CGRateS RPC <https://godoc.org/github.com/cgrates/cgrates/apier/>`_ via a rich set of *APIs*. As input **ChargerS** is capable of receiving generic events (hashmaps) with dynamic types for fields.
**ChargerS** is an **important** part of the charging process within **CGRateS** since with no *ChargingProfile* matching, there will be no billing run performed.

View File

@@ -1,32 +0,0 @@
DestinationRates.csv
++++++++++++++++++++
Attach rates to destinations.
CSV fields as tabular representation:
+--------------------+------------------+---------------------+
| Tag | DestinationsTag | RatesTag |
+====================+==================+=====================+
| DR_RETAIL_PEAK | GERMANY | LANDLINE_PEAK |
+--------------------+------------------+---------------------+
| DR_RETAIL_OFFPEAK | GERMANY | LANDLINE_OFFPEAK |
+--------------------+------------------+---------------------+
**Fields**
Index 0 - *Tag*
Free-text field used to reference the entry from other files.
Index 1 - *DestinationsTag*
References profile in Destinations.csv_.
Index 2 - *RatesTag*
References profile defined in Rates.csv_.
.. _Destinations.csv: csv_tpdestinations.rst
.. _Rates.csv: csv_tprates.rst

View File

@@ -1,21 +0,0 @@
Destinations.csv
++++++++++++++++
Group together prefixes into destination groups identified by tag.
CSV fields example as tabular representation:
+------------+--------+
| Tag | Prefix |
+============+========+
| GERMANY | 49 |
+------------+--------+
| GERMANY_O2 | 49176 |
+------------+--------+
Index 0 - *Tag*
Free-text field used to reference the specific destination from other files.
Index 1 - *Prefix*
Destination prefix as group element

View File

@@ -1,35 +0,0 @@
DestinationRateTimings.csv
++++++++++++++++++++++++++
Enable DestinationRates at specific times.
CSV fields examples as tabular representations:
+-----------------+----------------------+-----------+--------+
| Tag | DestinationRatesTag | TimingTag | Weight |
+=================+======================+===========+========+
| RETAIL1 | DR_RETAIL_PEAK | PEAK | 10 |
+-----------------+----------------------+-----------+--------+
| RETAIL1 | DR_FREESWITCH_USERS | ALWAYS | 10 |
+-----------------+----------------------+-----------+--------+
**Fields**
Index 0 - *Tag*
Free-text field used to reference the entry from other files.
Index 1 - *DestinationRatesTag*
References profile in DestinationRates.csv_.
Index 2 - *TimingTag*
References profile defined in Timings.csv_.
Index 3 - *Weight*
Solves possible conflicts between different DestinationRateTimings profiles matching on same interval.
Higher *Weight* has higher priority.
.. _DestinationRates.csv: csv_tpdestinationrates.html
.. _Timings.csv: csv_tptimings.html

View File

@@ -1,77 +0,0 @@
Rates.csv
+++++++++
Defines the rates on the system.
Each entry is a part of a rate group, each group having at least one entry. Group entries share *Tag*, *ConnectFee*, *Weight* parameters.
CSV fields example as tabular representation:
+---------------------+------------+------+----------+---------------+--------------------+----------------+------------------+---------+
| Tag | ConnectFee | Rate | RateUnit | RateIncrement | GroupIntervalStart | RoundingMethod | RoundingDecimals | Weight |
+=====================+============+======+==========+===============+====================+================+==================+=========+
| LANDLINE_PEAK | 0.02 | 0.02 | 60s | 60s | 0s | \*up | 4 | 10 |
+---------------------+------------+------+----------+---------------+--------------------+----------------+------------------+---------+
| MOBILE_PEAK | 1 | 2 | 60s | 10s | 0s | \*middle | 4 | 10 |
+---------------------+------------+------+----------+---------------+--------------------+----------------+------------------+---------+
| MOBILE_PEAK | 1 | 1 | 60s | 20s | 40s | \*middle | 4 | 10 |
+---------------------+------------+------+----------+---------------+--------------------+----------------+------------------+---------+
| MOBILE_PEAK | 1 | 0 | 60s | 10s | 60s | \*middle | 4 | 10 |
+---------------------+------------+------+----------+---------------+--------------------+----------------+------------------+---------+
Index 0 - *Tag*
Free-text field used to reference the entry from other files.
Index 1 - *ConnectFee*
Connect fee charged at start of each call. Should be the same for all members of a group interval.
Possible values:
* Float or integer value, granularity given by rates administrator and not predefined (eg: cent vs euro).
Index 2 - *Rate*
The rate which will be charged.
Possible values:
* Float or integer value, granularity given by rates administrator and not predefined (eg: cent vs euro).
Index 3 - *RateUnit*
The duration unit which is rated by *Rate* field.
Possible values:
* Duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
Index 4 - *RateIncrement*
The total duration will be split and rounded into smaller intervals based on this (eg: for *RateIncrement* of 60s, total duration of 1m2s will be charged as 2 minutes).
Possible values:
* Duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
Index 5 - *GroupIntervalStart*
The position in the rate group.
Possible values:
* Duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
Index 6 - *RoundingMethod*
The routine which will round the cost on each timespan.
Possible values:
* A *MetaTag* referring the internal routine doing the rounding (eg: \*up, \*down, \*middle)
Index 7 - *RoundingDecimals*
Round the number of decimals of each timespan based on this setting.
Possible values:
* An integer value.
Index 8 - *Weight*
Solve possible conflicts between different rates matching same interval based on this parameter.
Higher *Weight* has bigger priority.
Should be the same for all members of a group interval.
Possible values:
* Float/Integer representing the rate weight on collisions.

View File

@@ -1,39 +0,0 @@
RatingProfiles.csv
++++++++++++++++++
Main definitions file for the Rating subsystem.
+------------------+------+-----------+---------+-----------------------+----------------------------+----------------------+
| Tenant | ToR | Direction | Subject | ActivationTime | DestinationRateTimingTag | RatesFallbackSubject |
+==================+======+===========+=========+=======================+============================+======================+
| cgrates.org | call | \*out | \*any | 2012-01-01T00:00:00Z | RETAIL1 | |
+------------------+------+-----------+---------+-----------------------+----------------------------+----------------------+
**Fields**
Index 0 - *Tenant*
Free-text field used to identify the tenant the entries are valid for.
Index 1 - *ToR*
Free-text field used to identify the type of record the entries are valid for.
Index 2 - *Direction*
*Metatag* identifying the traffic direction the entries are valid for. Outbound direction is the only one supported for now.
Index 3 - *Subject*
Rating subject definition.
Possible values:
* Free-text rating subject (flexible defition for example out of concatenating various cdr fields)
* "\*any" metatag matching any rating subject in the eventuality of no explicit subject string matching.
Index 4 - *ActivationTime*
Time this rating profile gets active at.
Possible values:
* RFC3339 time as string
* Unix timestamp
* String starting with "+" to represent duration dynamically calculated at runtime (eg: +1h to specify ActivationTime one hour after runtime).
* "\*monthly" metatag for ActivationTime dynamically calculated one month after runtime.
Index 4 - *DestinationRateTimingTag*
References profile in DestinationRateTimings.csv_.
Index 5 - *RatesFallbackSubject*
Name of the fallback subject to be considered if existing subject has no destination matching the one searched. *Tenant*, *ToR*, *Direction*, *Subject* are kept when matching the fallback profile.
.. _DestinationRateTimings.csv: csv_tpdestinationrates.html

View File

@@ -1,60 +0,0 @@
Timings.csv
+++++++++++
Holds time related definitions.
CSV fields examples as tabular representations:
+-----------------+--------+--------+-----------+-----------+----------+
| Tag | Years | Months | MonthDays | WeekDays | Time |
+=================+========+========+===========+===========+==========+
| WORKDAYS | \*any | \*any | \*any | 1;2;3;4;5 | 00:00:00 |
+-----------------+--------+--------+-----------+-----------+----------+
| WEEKENDS | \*any | \*any | \*any | 6;7 | 00:00:00 |
+-----------------+--------+--------+-----------+-----------+----------+
| ALWAYS | \*any | \*any | \*any | \*any | 00:00:00 |
+-----------------+--------+--------+-----------+-----------+----------+
| ASAP | \*any | \*all | \*all | \*all | \*asap |
+-----------------+--------+--------+-----------+-----------+----------+
**Fields**
Index 0 - *Tag*
Free-text field used to reference the entry from other files.
Index 1 - *Years*
Years this timing is valid on.
Possibile values:
* Semicolon (;) separated list of years as descriptive filter.
* "\*any" metatag used as match-any filter.
Index 2 - *Months*
Months this timing is valid on.
Possibile values:
* Semicolon (;) separated list of months as descriptive filter.
* "\*any" metatag used as match-any filter.
Index 3 - *MonthDays*
Days of a month this timing is valid on.
Possibile values:
* Semicolon (;) separated list of month days as descriptive filter.
* "\*any" metatag used as match-any filter.
Index 4 - *WeekDays*
Days of a week this timing is valid on. Week days represented as integers where 1=Monday and 7=Sunday
Possibile values:
* Semicolon (;) separated list of week days as descriptive filter.
* "\*any" metatag used as match-any filter.
Index 4 - *Time*
The start time for this time period.
Possible values:
* String representation of time (hh:mm:ss).
* "\*asap" metatag used to represent time converted at runtime.

View File

@@ -1,3 +1,5 @@
.. _datadb:
DataDB
======

View File

@@ -1,37 +0,0 @@
DerivedCharging
===============
DerivedCharging is the process of forking original request into a number (configured) of emulated ones, derived from the original parameters. This mechanism used in combination with multi-tenancy supported by default by **CGRateS** can give out complex charging scenarios, needed for example in case of whitelabel-ing.
DerivedCharging occurs in two separate places:
- SessionManager: necessary to handle each derived (emulated) session in it's individuall loop (eg: individual resellers will have their own charging policies implemented, some paying per minute, others per second and so on) and keep them in sync (eg: one reseller is left out of money, original call should be disconnected and all emulated sessions should end their debit loops).
- Mediator: necessary to fork the CDRs into a number of derived ones influenced by the derived charging configuration and rate them individually.
Configuration
-------------
DerivedCharging is configured in two places:
- Platform level configured within *cgrates.cfg* file.
- Account level configured as part of TarrifPlans defition or interactively via RPC methods.
One DerivedCharger object will be configured by an internal object like:
::
type DerivedCharger struct {
RunId string // Unique runId in the chain
RunFilters string // Only run the charger if all the filters match
ReqTypeField string // Field containing request type info, number in case of csv source, '^' as prefix in case of static values
DirectionField string // Field containing direction info
TenantField string // Field containing tenant info
CategoryField string // Field containing tor info
AccountField string // Field containing account information
SubjectField string // Field containing subject information
DestinationField string // Field containing destination information
SetupTimeField string // Field containing setup time information
AnswerTimeField string // Field containing answer time information
UsageField string // Field containing usage information
}
**CGRateS** is able to attach an unlimited number of DerivedChargers to a single request, based on configuration.

View File

@@ -1,4 +1,4 @@
.. _FreeSWITCH: http://www.freeswitch.org
.. _FreeSWITCH: https://freeswitch.com
FreeSWITCH integration

View File

@@ -1,19 +0,0 @@
Rating history
==============
Enhances CGRateS with ability to archive rates modifications.
Large scaling posibility using server-agents approach.
In a distributed environment, there will be a single server (which can be backed up using technologies such as Linux-HA) and more agents sending the modifications to be archived.
History-Agent
-------------
Integrated in the rating loader components.
Part of *cgr-engine* and *cgr-loader*.
Enabled via *history_agent* configuration section within *cgr-engine* and *history_server* command line parameter in case of *cgr-loader*.
Sends the complete rating data loaded into dataDb to *history_server* for archiving.

View File

@@ -1,244 +0,0 @@
.. _data-importing:
Data importing
==============
For importing the data into CGRateS database we are using cvs files. The import process can be started as many times it is desired with one ore more csv files and the existing values are overwritten. If the -flush option is used then the database is cleaned before importing.For more details see the cgr-loader tool from the tutorial chapter.
The rest of this section we will describe the content of every csv files.
Rates profile
--------------
The rates profile describes the prices to be applied for various calls to various destinations in various time frames. When a call is made the CGRateS system will locate the rates to be applied to the call using the rating profiles.
+------------+-----+-----------+-------------+----------------------+----------------+----------------------+
| Tenant | ToR | Direction | Subject | RatesFallbackSubject | RatesTimingTag | ActivationTime |
+============+=====+===========+=============+======================+================+======================+
| CUSTOMER_1 | 0 | OUT | rif:from:tm | danb | PREMIUM | 2012-01-01T00:00:00Z |
+------------+-----+-----------+-------------+----------------------+----------------+----------------------+
| CUSTOMER_1 | 0 | OUT | rif:from:tm | danb | STANDARD | 2012-02-28T00:00:00Z |
+------------+-----+-----------+-------------+----------------------+----------------+----------------------+
Tenant
Used to distinguish between carriers if more than one share the same database in the CGRates system.
ToR
Type of record specifies the kind of transmission this rate profile applies to.
Direction
Can be IN or OUT for the INBOUND and OUTBOUND calls.
Subject
The client/user for who this profile is detailing the rates.
RatesFallbackSubject
This specifies another profile to be used in case the call destination will not be found in the current profile. The same tenant, tor and direction will be used.
RatesTimingTag
Forwards to a tag described in the rates timing file to be used for this profile.
ActivationTime
Multiple rates timings/prices can be created for one profile with different activation times. When a call is made the appropriate profile(s) will be used to rate the call. So future prices can be defined here and the activation time can be set as appropriate.
Rates timing
~~~~~~~~~~~~
This file makes links between a ratings and timings so each of them can be described once and various combinations are made possible.
+----------+----------------+--------------+--------+
| Tag | RatesTag | TimingTag | Weight |
+==========+================+==============+========+
| STANDARD | RT_STANDARD | WORKDAYS_00 | 10 |
+----------+----------------+--------------+--------+
| STANDARD | RT_STD_WEEKEND | WORKDAYS_18 | 10 |
+----------+----------------+--------------+--------+
Tag
A string by witch this rates timing will be referenced in other places by.
RatesTag
The rating tag described in the rates file.
TimingTag
The timing tag described in the timing file
Weight
If multiple timings cab be applied to a call the one with the lower weight wins. An example here can be the Christmas day: we can have a special timing for this day but the regular day of the week timing can also be applied to this day. The weight will differentiate between the two timings.
Rates
~~~~~
Defines price groups for various destinations which will be associated to various timings.
+---------------------+-----------------+------------+-------+-------------+
| Tag | DestinationsTag | ConnectFee | Price | BillingUnit |
+=====================+=================+============+=======+=============+
| RT_STANDARD | GERMANY | 0 | 0.2 | 1 |
+---------------------+-----------------+------------+-------+-------------+
| RT_STANDARD | GERMANY_O2 | 0 | 0.1 | 1 |
+---------------------+-----------------+------------+-------+-------------+
Tag
A string by witch this rate will be referenced in other places by.
DestinationsTag
The destination tag witch these rates apply to.
ConnectFee
The price to be charged once at the beginning of the call to the specified destination.
Price
The price for the billing unit expressed in cents.
BillingUnit
The billing unit expressed in seconds
Timings
~~~~~~~
Describes the time periods that have different rates attached to them.
+-----------------+--------+-----------+-----------+----------+
| Tag | Months | MonthDays | WeekDays | StartTime|
+=================+========+===========+===========+==========+
| WORKDAYS | \*all | \*all | 1;2;3;4;5 | 00:00:00 |
+-----------------+--------+-----------+-----------+----------+
| WEEKENDS | \*all | \*all | 6,7 | 00:00:00 |
+-----------------+--------+-----------+-----------+----------+
| DAILY_SAME_TIME | \*all | \*all | \*all | \*now |
+-----------------+--------+-----------+-----------+----------+
| ONE_TIME_RUN | \*none | \*none | \*none | \*now |
+-----------------+--------+-----------+-----------+----------+
Tag
A string by witch this timing will be referenced in other places by.
Months
Integers from 1=January to 12=December separated by semicolons (;) specifying the months for this time period.
MonthDays
Integers from 1 to 31 separated by semicolons (;) specifying the month days for this time period.
WeekDays
Integers from 1=Monday to 7=Sunday separated by semicolons (;) specifying the week days for this time period.
StartTime
The start time for this time period. \*now will be replaced with the time of the data importing.
Destinations
~~~~~~~~~~~~
The destinations are binding together various prefixes / caller ids to define a logical destination group. A prefix can appear in multiple destination groups.
+------------+--------+
| Tag | Prefix |
+============+========+
| GERMANY | 49 |
+------------+--------+
| GERMANY_O2 | 49176 |
+------------+--------+
Tag
A string by witch this destination will be referenced in other places by.
Prefix
The prefix or caller id to be added to the specified destination.
Account actions
---------------
Describes the actions to be applied to the clients/users accounts. There are two kinds of actions: timed and triggered. For the timed actions there is a scheduler application that reads them from the database and executes them at the appropriate timings. The triggered actions are executed when the specified balance counters reach certain thresholds.
The accounts hold the various balances and counters to activate the triggered actions for each the client.
Balance types are: MONETARY, SMS, INTERNET, INTERNET_TIME, MINUTES.
+------------+---------+-----------+------------------+------------------+
|Tenant | Account | Direction | ActionTimingsTag | ActionTriggersTag|
+============+=========+===========+==================+==================+
| CUSTOMER_1 | rif | OUT | STANDARD_ABO | STANDARD_TRIGGER |
+------------+---------+-----------+------------------+------------------+
| CUSTOMER_1 | dan | OUT | STANDARD_ABO | STANDARD_TRIGGER |
+------------+---------+-----------+------------------+------------------+
Tenant
Used to distinguish between carriers if more than one share the same database in the CGRates system.
Account
The identifier for the user's account.
Direction
Can be IN or OUT for the INBOUND and OUTBOUND calls.
ActionTimingsTag
Forwards to a timed action group that will be used on this account.
ActionTriggersTag
Forwards to a triggered action group that will be applied to this account.
Action triggers
~~~~~~~~~~~~~~~
For each account there are counters that record the activity on various balances. Action triggers allow when a counter reaches a threshold to activate a group of actions. After the execution the action trigger is marked as used and will no longer be evaluated until the triggers are reset. See actions for action trigger resetting.
+------------------+------------+----------------+----------------+------------+--------+
| Tag | BalanceTag | ThresholdValue | DestinationTag | ActionsTag | Weight |
+==================+============+================+================+============+========+
| STANDARD_TRIGGER | MONETARY | 30 | \*all | SOME_1 | 10 |
+------------------+------------+----------------+----------------+------------+--------+
| STANDARD_TRIGGER | SMS | 30 | \*all | SOME_2 | 10 |
+------------------+------------+----------------+----------------+------------+--------+
Tag
A string by witch this action trigger will be referenced in other places by.
BalanceTag
Specifies the balance counter by which this action will be triggered. Can be MONETARY, SMS, INTERNET, INTERNET_TIME, MINUTES.
ThresholdValue
The value of the balance counter that will trigger this action.
DestinationTag
This field is used only if the balanceTag is MINUTES. If the balance counter monitors call minutes this field indicates the destination of the calls for which the minutes are recorded.
ActionsTag
Forwards to an action group to be executed when the threshold is reached.
Weight
Specifies the order for these triggers to be evaluated. If there are multiple triggers are fired in the same time the ones with the lower weight will be executed first.
Action timings
~~~~~~~~~~~~~~
+--------------+------------+------------------+--------+
| Tag | ActionsTag | TimingTag | Weight |
+==============+============+==================+========+
| STANDARD_ABO | SOME | WEEKLY_SAME_TIME | 10 |
+--------------+------------+------------------+--------+
| STANDARD_ABO | SOME | WEEKLY_SAME_TIME | 10 |
+--------------+------------+------------------+--------+
Tag
A string by witch this action timing will be referenced in other places by.
ActionsTag
Forwards to an action group to be executed when the timing is right.
TimingTag
A timing (one time or recurrent) at which the action group will be executed
Weight
Specifies the order for these timings to be evaluated. If there are multiple action timings set to be execute on the same time the ones with the lower weight will be executed first.
Actions
~~~~~~~
+--------+-------------+------------+-------+----------------+-----------+------------+---------------+--------+
| Tag | Action | BalanceTag | Units | DestinationTag | PriceType | PriceValue | MinutesWeight | Weight |
+========+=============+============+=======+================+===========+============+===============+========+
| SOME | TOPUP_RESET | MONETARY | 10 | \*all | | | | 10 |
+--------+-------------+------------+-------+----------------+-----------+------------+---------------+--------+
| SOME_1 | DEBIT | MINUTES | 10 | GERMANY_O2 | PERCENT | 25 | 10 | 10 |
+--------+-------------+------------+-------+----------------+-----------+------------+---------------+--------+
Tag
A string by witch this action will be referenced in other places by.
Action
The action type. Can have one of the following:
+ LOG: Logs the other action values (for debugging purposes).
+ RESET_TRIGGERS: Marks all action triggers as ready to be executed.
+ SET_POSTPAID: Sets account to postpaid, maintains it's balances.
+ RESET_POSTPAID: Set account to postpaid, reset all it's balances.
+ SET_PREPAID: Sets account to prepaid, maintains it's balances. Makes sense after an account was set to POSTPAID and admin wants it back.
+ RESET_PREPAID: Set account to prepaid, reset all it's balances.
+ TOPUP_RESET: Add account balance. If previous balance found of the same type, reset it before adding.
+ TOPUP: Add account balance. If the specific balance is not defined, define it (eg: minutes per destination).
+ DEBIT: Debit account balance.
+ RESET_COUNTER: Sets the counter for the BalanceTag to 0
+ RESET_ALL_COUNTERS: Sets all counters to 0
BalanceTag
The balance on which the action will operate
Units
The units which will be operated on the balance BalanceTag.
DestinationTag
This field is used only if the balanceTag is MINUTES. Specifies the destination of the minutes to be operated.
PriceType
This field is used only if the balanceTag is MINUTES. Specifies if the minutes price will be absolute or a percent of the normal price, Can be ABSOLUTE or PERCENT. If the value is percent the
PriceValue
This field is used only if the balanceTag is MINUTES. The price for each second.
MinutesWeight
This field is used only if the balanceTag is MINUTES. If more minute balances are suitable for a call the one with smaller weight will be used first.
Weight
If there are multiple actions in a group, they will be executed in the order of their weight (smaller first).

View File

@@ -1,7 +1,7 @@
.. _Redis: http://redis.io
.. _MySQL: http://www.mysql.org
.. _PostgreSQL: http://www.postgresql.org
.. _MongoDB: http://www.mongodb.org
.. _Redis: https://redis.io/
.. _MySQL: https://dev.mysql.com/
.. _PostgreSQL: https://www.postgresql.org/
.. _MongoDB: https://www.mongodb.com/
@@ -51,7 +51,7 @@ Update & install:
sudo apt-get install cgrates
Once the installation is completed, one should perform the :ref:`post-install` section in order to have the CGRateS properly set and ready to run.
Once the installation is completed, one should perform the :ref:`post-install <post_install>` section in order to have the CGRateS properly set and ready to run.
After *post-install* actions are performed, CGRateS will be configured in **/etc/cgrates/cgrates.json** and enabled in **/etc/default/cgrates**.
@@ -94,7 +94,7 @@ To install CGRateS out of YUM execute the following commands
sudo yum update
sudo yum install cgrates
Once the installation is completed, one should perform the :ref:`post-install` section in order to have the CGRateS properly set and ready to run.
Once the installation is completed, one should perform the :ref:`post-install <post_install>` section in order to have the CGRateS properly set and ready to run.
After *post-install* actions are performed, CGRateS will be configured in **/etc/cgrates/cgrates.json** and enabled in **/etc/default/cgrates**.
@@ -178,7 +178,7 @@ Install Custom Debian / Ubuntu Package
Generate RPM Packages from Source
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Prerequisites
* :ref:`Install Golang <InstallGO>`
@@ -209,7 +209,8 @@ Execute the following commands
rpmbuild -bb --define "_topdir $HOME/cgr_build" SPECS/cgrates.spec
.. _post-install:
.. _post_install:
Post-install
------------

View File

@@ -1,85 +0,0 @@
LCR System
==========
In voice telecommunications, least-cost routing (LCR) is the process of selecting the path of outbound communications traffic based on cost. Within a telecoms carrier, an LCR team might periodically (monthly, weekly or even daily) choose between routes from several or even hundreds of carriers for destinations across the world. This function might also be automated by a device or software program known as a "Least Cost Router." [WIKI2015]_
Data structures
---------------
The LCR rule parameters are: Direction, Tenant, Category, Account, Subject, DestinationId, RPCategory, Strategy, StrategyParameters, ActivationTime, Weight.
The first five are used to match the rule for a specific call descriptor. They can have a value or marked as \*any.
The DestinationId can be used to filter the LCR rules entries or to make the rule more specific.
RPCategory is used to indicate the rating profile category.
Strategy indicates supplier selection algorithm and StrategyParams will be specific to each strategy. Strategy can be one of the following:
\*static (filter)
Will use the suppliers provided as params.
StrategyParams: suppier1;supplier2;etc
\*lowest_cost (sorting)
Matching suppliers will be sorted by ascending cost.
StrategyParams: None
\*highest_cost (sorting)
Matching suppliers will be sorted by descending cost.
StrategyParams: None
\*qos_with_threshold (filter)
The system will reject the suppliers that have out of bounds average success ratio or average call duration.
StrategyParams: min_asr;max_asr;min_acd;max_acd;min_tcd;max_tcd;min_acc;max_acc;min_tcc;max_tcc
\*qos (sorting)
The system will sort by metrics in the order of appearance.
StrategyParams: metric1;metric2;etc
\*load_distribution (sorting/filter)
The system will sort the suppliers in order to achieve the specified load distribution.
- if all have less than ratio return random order
- if some have a cdr count not divisible by ratio return them first and all ordered by cdr times, oldest first
- if all have a multiple of ratio return in the order of cdr times, oldest first
StrategyParams: supplier1:ratio;supplier2:ratio;*default:ratio
ActivationTime is the date/time when the LCR entry starts to be active.
Weight is used to sort the rules with the same activation time.
Example
+++++++
::
*in, cgrates.org,call,*any,*any,EU_LANDLINE,LCR_STANDARD,*static,ivo;dan;rif,2012-01-01T00:00:00Z,10
Code implementation
-------------------
The general process of getting LCRs is this.
The LCR rules for a specific call descriptor are searched using direction, tenant, category, account and subject of the call descriptor matched as strictly as possible with LCR rules.
Because a rule can have several entries they will be sorted by activation time.
Next the system will find out the most recent LCR entry that applies to this call considering entries activation times.
The LCR entry is processed according to it's strategy. For static strategy the cost is calculated for each supplier found in the parameters and the suppliers are listed as they are found.
For the QOS strategies the suppliers are searched using call descriptor parameters (direction, tenant, category, account, subject), than the cdrstats module is queried for the QOS values and the suppliers are filtered or sorted according to the StrategyParameters field. The suppliers that have the QOS parameters in the stats queues but did not get the chance to process any calls are favored in the QOS sorting algorithm. If a certain QOS metric is missing from the supplier queues than the metric is ignored and the sorting or filtering is done using the next metrics that are considered.
For the lowest/highest cost strategies the matched suppliers are sorted ascending/descending on cost.
::
{
"Entry": {
"DestinationId": "*any",
"RPCategory": "LCR_STANDARD",
"Strategy": "*lowest_cost",
"StrategyParams": "",
"Weight": 20
},
"SupplierCosts": [{"Supplier":"rif", Cost:"2.0"},{"Supplier":"dan", Cost:"1.0"}]
}
.. [WIKI2015] http://en.wikipedia.org/wiki/Least-cost_routing

View File

@@ -2,8 +2,8 @@
.. _Go: http://golang.org
.. _Docker: https://www.docker.com/
.. _Kafka: https://kafka.apache.org/
.. _redis: http://redis.io
.. _mongodb: http://www.mongodb.org
.. _redis: https://redis.io/
.. _mongodb: https://www.mongodb.com/
.. _api docs: https://godoc.org/github.com/cgrates/cgrates/apier
.. _SQS: https://aws.amazon.com/de/sqs/
.. _AMQP: https://www.amqp.org/

View File

@@ -1,8 +1,10 @@
.. _rals:
RALs
====
**RALs** is a standalone subsystem within **CGRateS** designed to handle two major tasks: :ref:`Rating` and :ref:`Accounting`. It is accessed via :ref:`CGRateS RPC APIs<remote-management>`.
**RALs** is a standalone subsystem within **CGRateS** designed to handle two major tasks: :ref:`Rating` and :ref:`Accounting`. It is accessed via `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_.
@@ -377,7 +379,7 @@ LastExecutionTime
Action
------
Actions are routines executed on demand (ie. by one of the three subsystems: :ref:`SchedulerS`, :ref:`ThresholdS` or :ref:`ActionTriggers`) or called by API by external scripts.
Actions are routines executed on demand (ie. by one of the three subsystems: :ref:`SchedulerS`, :ref:`ThresholdS` or :ref:`ActionTriggers <ActionTrigger>`) or called by API by external scripts.
An *Action has the following parameters:
@@ -424,7 +426,7 @@ ActionType
Debit the value from the :ref:`Balance` matching the filters.
**\*reset_counters**
Reset the :ref:`Balance` counters (used by :ref:`ActionTriggers <ActionTrigger>).
Reset the :ref:`Balance` counters (used by :ref:`ActionTriggers <ActionTrigger>`).
**\*enable_account**
Unset the :ref:`Account` *Disabled* flag.

View File

@@ -1,730 +0,0 @@
2. User Life Cycle
==================
Following steps will cover use-case "User Life cycle"
2.1 User Management
-------------------
2.1.1 Create User Account
#########################
:Hint:
cgr> account_set Tenant="cgrates.org" Account="1003" ActionPlanIDs=["PACKAGE_10"] ActionTriggerIDs=["STANDARD_TRIGGERS"]
*Request*
::
{
"method": "APIerSv2.SetAccount",
"params": [{
"Tenant": "cgrates.org",
"Account": "1003",
"ActionPlanIDs": ["PACKAGE_10"],
"ActionPlansOverwrite": false,
"ActionTriggerIDs": ["STANDARD_TRIGGERS"],
"ActionTriggerOverwrite": false,
"AllowNegative": null,
"Disabled": null,
"ReloadScheduler": false
}],
"id": 0
}
*Response*
::
{"id": 0,"result": "OK","error": null}
2.1.2 Get User Account
######################
:Hint:
cgr> accounts Tenant="cgrates.org" AccountIds=["1003"]
*Request*
::
{
"method": "APIerSv2.GetAccounts",
"params": [{
"Tenant": "cgrates.org",
"AccountIds": ["1003"],
"Offset": 0,
"Limit": 0
}],
"id": 1
}
*Response*
::
{
"id": 1,
"result": [{
"ID": "cgrates.org:1003",
"BalanceMap": {
"*monetary": [{
"Uuid": "df24bcbd-d0e2-4a67-a188-7c9621ae81d7",
"ID": "",
"Value": 0.15,
"Directions": {
"*out": true
},
"ExpirationDate": "0001-01-01T00:00:00Z",
"Weight": 10,
"DestinationIDs": {},
"RatingSubject": "",
"Categories": {},
"SharedGroups": {},
"Timings": [],
"TimingIDs": {},
"Disabled": false,
"Factor": {},
"Blocker": false
}, {
"Uuid": "9a22f090-a49a-4da6-bdca-5e40810e4b18",
"ID": "23456",
"Value": 12,
"Directions": {},
"ExpirationDate": "0001-01-01T00:00:00Z",
"Weight": 0,
"DestinationIDs": {},
"RatingSubject": "",
"Categories": {},
"SharedGroups": {},
"Timings": [],
"TimingIDs": {},
"Disabled": false,
"Factor": {},
"Blocker": false
}, {
"Uuid": "4da21ba2-d899-49b1-ae60-3e8a237a49bb",
"ID": "123456",
"Value": 0.2,
"Directions": {
"*out": true
},
"ExpirationDate": "0001-01-01T00:00:00Z",
"Weight": 0,
"DestinationIDs": {},
"RatingSubject": "",
"Categories": {},
"SharedGroups": {},
"Timings": [],
"TimingIDs": {},
"Disabled": false,
"Factor": {},
"Blocker": false
}]
},
"UnitCounters": {
"*monetary": [{
"CounterType": "*event",
"Counters": [{
"Value": 0,
"Filter": {
"Uuid": null,
"ID": "df4d286a-445f-40a8-ab84-215153d4f2ac",
"Type": "*monetary",
"Value": null,
"Directions": {
"*out": true
},
"ExpirationDate": null,
"Weight": null,
"DestinationIDs": {
"FS_USERS": true
},
"RatingSubject": null,
"Categories": null,
"SharedGroups": null,
"TimingIDs": null,
"Timings": [],
"Disabled": null,
"Factor": null,
"Blocker": null
}
}]
}]
},
"ActionTriggers": [{
"ID": "STANDARD_TRIGGERS",
"UniqueID": "621cb77f-c427-445f-8dfc-05b8105a1709",
"ThresholdType": "*min_balance",
"ThresholdValue": 2,
"Recurrent": false,
"MinSleep": 0,
"ExpirationDate": "0001-01-01T00:00:00Z",
"ActivationDate": "0001-01-01T00:00:00Z",
"Balance": {
"Uuid": null,
"ID": null,
"Type": "*monetary",
"Value": null,
"Directions": {
"*out": true
},
"ExpirationDate": null,
"Weight": null,
"DestinationIDs": null,
"RatingSubject": null,
"Categories": null,
"SharedGroups": null,
"TimingIDs": null,
"Timings": [],
"Disabled": null,
"Factor": null,
"Blocker": null
},
"Weight": 10,
"ActionsID": "LOG_WARNING",
"MinQueuedItems": 0,
"Executed": true,
"LastExecutionTime": "2017-12-12T15:19:45.742Z"
}, {
"ID": "STANDARD_TRIGGERS",
"UniqueID": "df4d286a-445f-40a8-ab84-215153d4f2ac",
"ThresholdType": "*max_event_counter",
"ThresholdValue": 5,
"Recurrent": false,
"MinSleep": 0,
"ExpirationDate": "0001-01-01T00:00:00Z",
"ActivationDate": "0001-01-01T00:00:00Z",
"Balance": {
"Uuid": null,
"ID": "df4d286a-445f-40a8-ab84-215153d4f2ac",
"Type": "*monetary",
"Value": null,
"Directions": {
"*out": true
},
"ExpirationDate": null,
"Weight": null,
"DestinationIDs": {
"FS_USERS": true
},
"RatingSubject": null,
"Categories": null,
"SharedGroups": null,
"TimingIDs": null,
"Timings": [],
"Disabled": null,
"Factor": null,
"Blocker": null
},
"Weight": 10,
"ActionsID": "LOG_WARNING",
"MinQueuedItems": 0,
"Executed": false,
"LastExecutionTime": "0001-01-01T00:00:00Z"
}, {
"ID": "STANDARD_TRIGGERS",
"UniqueID": "cb60f788-6077-4f3c-b8b2-4d1ba3077abc",
"ThresholdType": "*max_balance",
"ThresholdValue": 20,
"Recurrent": false,
"MinSleep": 0,
"ExpirationDate": "0001-01-01T00:00:00Z",
"ActivationDate": "0001-01-01T00:00:00Z",
"Balance": {
"Uuid": null,
"ID": null,
"Type": "*monetary",
"Value": null,
"Directions": {
"*out": true
},
"ExpirationDate": null,
"Weight": null,
"DestinationIDs": null,
"RatingSubject": null,
"Categories": null,
"SharedGroups": null,
"TimingIDs": null,
"Timings": [],
"Disabled": null,
"Factor": null,
"Blocker": null
},
"Weight": 10,
"ActionsID": "LOG_WARNING",
"MinQueuedItems": 0,
"Executed": false,
"LastExecutionTime": "0001-01-01T00:00:00Z"
}, {
"ID": "STANDARD_TRIGGERS",
"UniqueID": "7f7621f4-6074-4502-bbc0-a8aeca7c1008",
"ThresholdType": "*max_balance",
"ThresholdValue": 100,
"Recurrent": false,
"MinSleep": 0,
"ExpirationDate": "0001-01-01T00:00:00Z",
"ActivationDate": "0001-01-01T00:00:00Z",
"Balance": {
"Uuid": null,
"ID": null,
"Type": "*monetary",
"Value": null,
"Directions": {
"*out": true
},
"ExpirationDate": null,
"Weight": null,
"DestinationIDs": null,
"RatingSubject": null,
"Categories": null,
"SharedGroups": null,
"TimingIDs": null,
"Timings": [],
"Disabled": null,
"Factor": null,
"Blocker": null
},
"Weight": 10,
"ActionsID": "DISABLE_AND_LOG",
"MinQueuedItems": 0,
"Executed": false,
"LastExecutionTime": "0001-01-01T00:00:00Z"
}],
"AllowNegative": false,
"Disabled": false
}],
"error": null
}
2.1.3 Remove User Account
#########################
:Hint:
cgr> account_remove Tenant="cgrates.org" Account="1003"
*Request*
::
{
"method": "APIerSv1.RemoveAccount",
"params": [{
"Tenant": "cgrates.org",
"Account": "1003",
"ReloadScheduler": false
}],
"id": 3
}
*Response*
::
{"id": 3,"result": "OK","error": null}
2.1.4 Get Users Profile
#######################
GetUsers returns list of all users profile:
:Hint:
cgr> users
*Request*
::
{
"method": "UsersV1.GetUsers",
"params": [{
"Tenant": "",
"UserName": "",
"Masked": false,
"Profile": null,
"Weight": 0
}],
"id": 2
}
*Response*
::
{
"id": 2,
"result": [{
"Tenant": "cgrates.org",
"UserName": "1001",
"Masked": false,
"Profile": {
"Account": "1001",
"Cli": "+4986517174963",
"RequestType": "*prepaid",
"Subject": "1001",
"SubscriberId": "1001",
"SysPassword": "hisPass321",
"SysUserName": "danb",
"Uuid": "388539dfd4f5cefee8f488b78c6c244b9e19138e"
},
"Weight": 0
},
{
"Tenant": "cgrates.org",
"UserName": "1002",
"Masked": false,
"Profile": {
"Account": "1002",
"RifAttr": "RifVal",
"Subject": "1002",
"SubscriberId": "1002",
"SysUserName": "rif",
"Uuid": "27f37edec0670fa34cf79076b80ef5021e39c5b5"
},
"Weight": 0
},
{
"Tenant": "cgrates.org",
"UserName": "1004",
"Masked": false,
"Profile": {
"Account": "1004",
"Cli": "+4986517174964",
"RequestType": "*rated",
"Subject": "1004",
"SubscriberId": "1004",
"SysPassword": "hisPass321",
"SysUserName": "danb4"
},
"Weight": 0
}
],
"error": null
}
2.1.5 Get Profile UserName 1001
###############################
Returns a User Profile of user account 1001:
:Hint:
cgr> users UserName="1001"
*Request*
::
{
"method": "UsersV1.GetUsers",
"params": [{
"Tenant": "",
"UserName": "1001",
"Masked": false,
"Profile": null,
"Weight": 0
}],
"id": 2
}
*Response*
::
{
"id": 2,
"result": [{
"Tenant": "cgrates.org",
"UserName": "1001",
"Masked": false,
"Profile": {
"Account": "1001",
"Cli": "+4986517174963",
"RequestType": "*prepaid",
"Subject": "1001",
"SubscriberId": "1001",
"SysPassword": "hisPass321",
"SysUserName": "danb",
"Uuid": "388539dfd4f5cefee8f488b78c6c244b9e19138e"
},
"Weight": 0
}],
"error": null
}
2.1.6 Get Action Plans
######################
Returns a list of all ActionPlans defined on user accounts:
:Hint:
cgr> actionplan_get
*Request*
::
{
"method": "APIerSv1.GetActionPlan",
"params": [{
"ID": ""
}],
"id": 3
}
*Response*
::
{
"id": 3,
"result": [{
"Id": "PACKAGE_10_SHARED_A_5",
"AccountIDs": null,
"ActionTimings": [{
"Uuid": "93e8cb80-7dad-4efc-8d65-1e0e61ce219d",
"Timing": {
"Timing": {
"Years": null,
"Months": null,
"MonthDays": null,
"WeekDays": null,
"StartTime": "*asap",
"EndTime": ""
},
"Rating": null,
"Weight": 0
},
"ActionsID": "TOPUP_RST_5",
"Weight": 10
}, {
"Uuid": "a4ac319b-144a-49e6-b87f-8878c8adc495",
"Timing": {
"Timing": {
"Years": null,
"Months": null,
"MonthDays": null,
"WeekDays": null,
"StartTime": "*asap",
"EndTime": ""
},
"Rating": null,
"Weight": 0
},
"ActionsID": "TOPUP_RST_SHARED_5",
"Weight": 10
}]
},
{
"Id": "PACKAGE_1001",
"AccountIDs": {
"cgrates.org:1001": true
},
"ActionTimings": [{
"Uuid": "8261378b-aa47-45c8-a0ad-6fb4a61358a6",
"Timing": {
"Timing": {
"Years": null,
"Months": null,
"MonthDays": null,
"WeekDays": null,
"StartTime": "*asap",
"EndTime": ""
},
"Rating": null,
"Weight": 0
},
"ActionsID": "TOPUP_RST_5",
"Weight": 10
}, {
"Uuid": "a1360fae-d9e9-4a6f-9b29-c4dcdd56b266",
"Timing": {
"Timing": {
"Years": null,
"Months": null,
"MonthDays": null,
"WeekDays": null,
"StartTime": "*asap",
"EndTime": ""
},
"Rating": null,
"Weight": 0
},
"ActionsID": "TOPUP_RST_SHARED_5",
"Weight": 10
}, {
"Uuid": "f3ed64ba-a158-4302-ad46-98646cad8a8f",
"Timing": {
"Timing": {
"Years": null,
"Months": null,
"MonthDays": null,
"WeekDays": null,
"StartTime": "*asap",
"EndTime": ""
},
"Rating": null,
"Weight": 0
},
"ActionsID": "TOPUP_120_DST1003",
"Weight": 10
}, {
"Uuid": "1a5c69fb-c5f8-4852-8c66-5afd296fa5e4",
"Timing": {
"Timing": {
"Years": null,
"Months": null,
"MonthDays": null,
"WeekDays": null,
"StartTime": "*asap",
"EndTime": ""
},
"Rating": null,
"Weight": 0
},
"ActionsID": "TOPUP_RST_DATA_100",
"Weight": 10
}]
},
{
"Id": "PACKAGE_10",
"AccountIDs": {
"cgrates.org:1002": true,
"cgrates.org:1003": true,
"cgrates.org:1004": true
},
"ActionTimings": [{
"Uuid": "6e335f92-ae2e-4253-8809-f124a46eac06",
"Timing": {
"Timing": {
"Years": null,
"Months": null,
"MonthDays": null,
"WeekDays": null,
"StartTime": "*asap",
"EndTime": ""
},
"Rating": null,
"Weight": 0
},
"ActionsID": "TOPUP_RST_10",
"Weight": 10
}]
}, {
"Id": "USE_SHARED_A",
"AccountIDs": {
"cgrates.org:1007": true
},
"ActionTimings": [{
"Uuid": "eee41fa1-aa24-4795-b875-37213473ad3d",
"Timing": {
"Timing": {
"Years": null,
"Months": null,
"MonthDays": null,
"WeekDays": null,
"StartTime": "*asap",
"EndTime": ""
},
"Rating": null,
"Weight": 0
},
"ActionsID": "SHARED_A_0",
"Weight": 10
}]
}
],
"error": null
}
2.1.7 Get Action Plans of one Package ID
########################################
Returns a list of accounts where ActionPlan for "PACKAGE_10" is allocated:
:Hint:
cgr> actionplan_get ID="PACKAGE_10"
*Request*
::
{
"method": "APIerSv1.GetActionPlan",
"params": [{
"ID": "PACKAGE_10"
}],
"id": 4
}
*Response*
::
{
"id": 4,
"result": [{
"Id": "PACKAGE_10",
"AccountIDs": {
"cgrates.org:1002": true,
"cgrates.org:1003": true,
"cgrates.org:1004": true
},
"ActionTimings": [{
"Uuid": "6e335f92-ae2e-4253-8809-f124a46eac06",
"Timing": {
"Timing": {
"Years": null,
"Months": null,
"MonthDays": null,
"WeekDays": null,
"StartTime": "*asap",
"EndTime": ""
},
"Rating": null,
"Weight": 0
},
"ActionsID": "TOPUP_RST_10",
"Weight": 10
}]
}],
"error": null
}
2.1.8 User Indexes
##################
:Hint:
cgr> user_indexes
*Request*
::
{
"method": "UsersV1.GetIndexes",
"params": [""],
"id": 2
}
*Response*
::
{
"id": 2,
"result": {
"Uuid:27f37edec0670fa34cf79076b80ef5021e39c5b5": ["cgrates.org:1002"],
"Uuid:388539dfd4f5cefee8f488b78c6c244b9e19138e": ["cgrates.org:1001"]
},
"error": null
}

View File

@@ -1,324 +0,0 @@
3. Balance Management
=====================
3.1 Balance Set
---------------
replaces existing value of BalanceID '23456' with value 12 for account 1003 belongs to tenant 'cgrates.org'
:Hint:
cgr> balance_set Tenant="cgrates.org" Account="1003" Direction="\*out" Value=12 BalanceID="23456"
*Request*
::
{
"method": "APIerSv1.SetBalance",
"params": [{
"Tenant": "cgrates.org",
"Account": "1003",
"BalanceType": "*monetary",
"BalanceUUID": null,
"BalanceID": "23456",
"Directions": null,
"Value": 12,
"ExpiryTime": null,
"RatingSubject": null,
"Categories": null,
"DestinationIds": null,
"TimingIds": null,
"Weight": null,
"SharedGroups": null,
"Blocker": null,
"Disabled": null
}],
"id": 6
}
*Response*
::
{"id":6,"result":"OK","error":null}
3.2 Balance Add
---------------
adds 10 cent to account=1003 where tenant=cgrates.org
:Hint:
cgr> balance_add Tenant="cgrates.org" Account="1003" BalanceId="123456" Value=10
*Request*
::
{
"method": "APIerSv1.AddBalance",
"params": [{
"Tenant": "cgrates.org",
"Account": "1003",
"BalanceUuid": null,
"BalanceId": "123456",
"BalanceType": "*monetary",
"Directions": null,
"Value": 10,
"ExpiryTime": null,
"RatingSubject": null,
"Categories": null,
"DestinationIds": null,
"TimingIds": null,
"Weight": null,
"SharedGroups": null,
"Overwrite": false,
"Blocker": null,
"Disabled": null
}],
"id": 4
}
*Response*
::
{"id":4,"result":"OK","error":null}
3.3 Balance Debit
-----------------
deducts 5 cents from account 1003 of tenant cgrates.org
:Hint:
cgr> balance_debit Tenant="cgrates.org" Account="1003" BalanceId="23456" Value=5 BalanceType="\*monetary"
*Request*
::
{
"method": "APIerSv1.DebitBalance",
"params": [{
"Tenant": "cgrates.org",
"Account": "1003",
"BalanceUuid": null,
"BalanceId": "23456",
"BalanceType": "*monetary",
"Directions": null,
"Value": 5,
"ExpiryTime": null,
"RatingSubject": null,
"Categories": null,
"DestinationIds": null,
"TimingIds": null,
"Weight": null,
"SharedGroups": null,
"Overwrite": false,
"Blocker": null,
"Disabled": null
}],
"id": 5
}
*Response*
::
{"id":5,"result":"OK","error":null}
3.4 Get Remaining Balance
-------------------------
Sum of BalanceMap.Value resulted from APIerSv2.GetAccounts request
3.5 Debit Air Time (TBV)
------------------------
:Hint:
cgr> debit Tenant="cgrates.org" Account="1001" CallDuration=500
*Request*
::
{
"method": "Responder.Debit",
"params": [{
"Direction": "*out",
"Category": "",
"Tenant": "cgrates.org",
"Subject": "",
"Account": "1001",
"Destination": "",
"TimeStart": "0001-01-01T00:00:00Z",
"TimeEnd": "0001-01-01T00:00:00Z",
"LoopIndex": 0,
"DurationIndex": 0,
"FallbackSubject": "",
"RatingInfos": null,
"Increments": null,
"ToR": "",
"ExtraFields": null,
"MaxRate": 0,
"MaxRateUnit": 0,
"MaxCostSoFar": 0,
"CgrID": "",
"RunID": "",
"ForceDuration": false,
"PerformRounding": false,
"DryRun": false,
"DenyNegativeAccount": false
}],
"id": 16
}
*Response*
::
{
"id": 16,
"result": {
"Direction": "*out",
"Category": "",
"Tenant": "cgrates.org",
"Subject": "1001",
"Account": "1001",
"Destination": "",
"ToR": "",
"Cost": 0,
"Timespans": null,
"RatedUsage": 0,
"AccountSummary": {
"Tenant": "cgrates.org",
"ID": "1001",
"BalanceSummaries": [{
"UUID": "a6fc6e96-de69-445b-8456-cebd78a1b43d",
"ID": "a6fc6e96-de69-445b-8456-cebd78a1b43d",
"Type": "*monetary",
"Value": 5,
"Disabled": false
}, {
"UUID": "9df5d845-e411-4edd-971c-d98dbb926054",
"ID": "9df5d845-e411-4edd-971c-d98dbb926054",
"Type": "*monetary",
"Value": 25,
"Disabled": false
}, {
"UUID": "4a4d07c8-9548-415d-a029-7e369bf02f60",
"ID": "4a4d07c8-9548-415d-a029-7e369bf02f60",
"Type": "*voice",
"Value": 120,
"Disabled": false
}, {
"UUID": "8d867c57-31b4-407d-afc7-fb4dc359ae4d",
"ID": "8d867c57-31b4-407d-afc7-fb4dc359ae4d",
"Type": "*voice",
"Value": 90,
"Disabled": false
}, {
"UUID": "66009d4e-25ed-47d6-8dfa-ef3c501fd1b0",
"ID": "66009d4e-25ed-47d6-8dfa-ef3c501fd1b0",
"Type": "*data",
"Value": 102400,
"Disabled": false
}],
"AllowNegative": false,
"Disabled": false
}
},
"error": null
}
3.6 Set Balance for Outbound Calls
----------------------------------
:Hint:
cgr> balance_set Tenant="cgrates.org" Account="1001" BalanceType="\*voice" Directions="\*out" Value=100 BalanceID="8d867c57-31b4-407d-afc7-fb4dc359ae4d"
*Request*
::
{
"method": "APIerSv1.SetBalance",
"params": [{
"Tenant": "cgrates.org",
"Account": "1001",
"BalanceType": "*voice",
"BalanceUUID": null,
"BalanceID": "8d867c57-31b4-407d-afc7-fb4dc359ae4d",
"Directions": "*out",
"Value": 100,
"ExpiryTime": null,
"RatingSubject": null,
"Categories": null,
"DestinationIds": null,
"TimingIds": null,
"Weight": null,
"SharedGroups": null,
"Blocker": null,
"Disabled": null
}],
"id": 18
}
*Response*
::
{
"id": 18,
"result": "OK",
"error": null
}
3.7 Set Balance for Inbound Calls
---------------------------------
:Hint:
cgr> balance_set Tenant="cgrates.org" Account="1001" BalanceType="\*voice" Directions="\*in" Value=600 BalanceID="9d867c57-31b4-407d-afc7-fb4dc359ae4d"
*Request*
::
{
"method": "APIerSv1.SetBalance",
"params": [{
"Tenant": "cgrates.org",
"Account": "1001",
"BalanceType": "*voice",
"BalanceUUID": null,
"BalanceID": "9d867c57-31b4-407d-afc7-fb4dc359ae4d",
"Directions": "*in",
"Value": 600,
"ExpiryTime": null,
"RatingSubject": null,
"Categories": null,
"DestinationIds": null,
"TimingIds": null,
"Weight": null,
"SharedGroups": null,
"Blocker": null,
"Disabled": null
}],
"id": 28
}
*Response*
::
{
"id": 28,
"result": "OK",
"error": null
}

View File

@@ -1,132 +0,0 @@
4. CDR Management
=================
4.1 Export CDRs
---------------
:Hint:
cgr > cdrs_export CdrFormat="csv" ExportDir="/tmp"
*Request*
::
{
"method": "APIerSv1.ExportCDRs",
"params": [{
"ExportTemplate": null,
"ExportFormat": null,
"ExportPath": null,
"Synchronous": null,
"Attempts": null,
"FieldSeparator": null,
"UsageMultiplyFactor": null,
"CostMultiplyFactor": null,
"ExportID": null,
"ExportFileName": null,
"RoundingDecimals": null,
"Verbose": false,
"CGRIDs": null,
"NotCGRIDs": null,
"RunIDs": null,
"NotRunIDs": null,
"OriginHosts": null,
"NotOriginHosts": null,
"Sources": null,
"NotSources": null,
"ToRs": null,
"NotToRs": null,
"RequestTypes": null,
"NotRequestTypes": null,
"Tenants": null,
"NotTenants": null,
"Categories": null,
"NotCategories": null,
"Accounts": null,
"NotAccounts": null,
"Subjects": null,
"NotSubjects": null,
"DestinationPrefixes": null,
"NotDestinationPrefixes": null,
"Costs": null,
"NotCosts": null,
"ExtraFields": null,
"NotExtraFields": null,
"OrderIDStart": null,
"OrderIDEnd": null,
"SetupTimeStart": "",
"SetupTimeEnd": "",
"AnswerTimeStart": "",
"AnswerTimeEnd": "",
"CreatedAtStart": "",
"CreatedAtEnd": "",
"UpdatedAtStart": "",
"UpdatedAtEnd": "",
"MinUsage": "",
"MaxUsage": "",
"MinCost": null,
"MaxCost": null,
"Limit": null,
"Offset": null,
"SearchTerm": ""
}],
"id": 8
}
*Response*
::
{
"id": 8,
"result": {
"ExportedPath": "/var/spool/cgrates/cdre/cdre_1513199075.csv",
"TotalRecords": 186,
"TotalCost": 56.4371,
"FirstOrderID": 1513066080275428946,
"LastOrderID": 1513066080275429038,
"ExportedCGRIDs": null,
"UnexportedCGRIDs": null
},
"error": null
}
"/var/spool/cgrates/cdre/cdre_1513199075.csv" is the destination cdr file in csv format.
4.2 CDR Stats for Queues
------------------------
Return list of Queue IDs
:Hint:
cgr> cdrstats_queueids
*Request*
::
{
"method": "CDRStatsV1.GetQueueIds",
"params": [""],
"id": 8
}
*Response*
::
{
"id": 8,
"result": [
"CDRST_1003",
"CDRST1",
"CDRST_1001",
"CDRST_1002",
"STATS_SUPPL1",
"STATS_SUPPL2"
],
"error": null
}

View File

@@ -1,22 +0,0 @@
.. CGRateS documentation master file, created by
sphinx-quickstart on Mon Mar 5 10:59:27 2012.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
CGRateS API Document!
=====================
Full contents:
==============
.. toctree::
:maxdepth: 2
introduction
accountLifeCycle
balanceManagement
cdrManagement
lcrStrategies
tariffPlanManagement
suppliersManagement
misc

View File

@@ -1,22 +0,0 @@
1. Introduction
===============
`CGRateS` is a *very fast* and *easily scalable* **(charging, rating, accounting, lcr, mediation, billing, authorization)** *ENGINE* targeted especially for ISPs and Telecom Operators. It allow users provisioning and tarif plan management.
It is written in `Go` programming language and is accessible from any programming language via JSON RPC.
*Usage example through cgr-console*
:Hint:
cgr> Accounts Tenant="cgrates.org" AccountIDs=["1001"]
*Usage example through postman*
URL: http://your_server_ip:2080/jsonrpc
*Request*
::
{"method":"APIerSv2.GetAccounts","params":[{"Tenant":"cgrates.org","AccountIds":["1001"],"Offset":0,"Limit":0}],"id":3}
Content-Type: application/json

View File

@@ -1,42 +0,0 @@
5. LCR Strategies
=================
5.1 LCR Strategy: (\*static)
----------------------------
Use supplier base on LCR rules
:Hint:
cgr> lcr Account="1001" Destination="1002"
5.2 LCR Strategy: (\*lowest_cost)
---------------------------------
Use supplier with least cost
:Hint:
cgr> lcr Account="1005" Destination="1001"
5.3 LCR Strategy: (\*highest_cost)
----------------------------------
Use supplier with highest cost
:Hint:
cgr> lcr Account="1002" Destination="1002"
5.4 LCR Strategy: (\*qos_threshold)
-----------------------------------
Use supplier with lowest cost, matching QoS thresholds min/max ASR, ACD, TCD, ACC, TCC
:Hint:
cgr> lcr Account="1002" Destination="1002"
5.5 LCR Strategy: (\*qos)
-------------------------
Use supplier with best quality, independent of cost
:Hint:
cgr> lcr Account="1002" Destination="1005"

View File

@@ -1,48 +0,0 @@
8. GetCacheStats
================
GetCacheStats returns datadb cache status. Empty params return all stats:
:Hint:
cgr> cache_stats
*Request*
::
{
"method": "APIerSv1.GetCacheStats",
"params": [{}],
"id": 0
}
*Response:*
::
{
"id": 0,
"result": {
"Destinations": 0,
"ReverseDestinations": 0,
"RatingPlans": 4,
"RatingProfiles": 0,
"Actions": 0,
"ActionPlans": 4,
"AccountActionPlans": 0,
"SharedGroups": 0,
"DerivedChargers": 0,
"LcrProfiles": 0,
"CdrStats": 6,
"Users": 3,
"ResourceProfiles": 0,
"Resources": 0,
"StatQueues": 0,
"StatQueueProfiles": 0,
"Thresholds": 0,
"ThresholdProfiles": 0,
"Filters": 0
},
"error": null
}

View File

@@ -1,52 +0,0 @@
7. Suppliers Management
=======================
7.1 List Suppliers
------------------
:Hint:
suppliers Tenant="cgrates.org" ID="SPP_1"
*Request*
::
{
"method": "APIerSv1.GetSupplierProfile",
"params": [{
"Tenant": "cgrates.org",
"ID": "SPP_1"
}],
"id": 6
}
*Response*
::
{
"id": 6,
"result": {
"Tenant": "cgrates.org",
"ID": "SPP_1",
"FilterIDs": ["FLTR_ACNT_dan", "FLTR_DST_DE"],
"ActivationInterval": {
"ActivationTime": "2017-07-29T15:00:00Z",
"ExpiryTime": "0001-01-01T00:00:00Z"
},
"Sorting": "*lowest_cost",
"SortingParams": [],
"Suppliers": [{
"ID": "supplier1",
"FilterIDs": ["FLTR_ACNT_dan"],
"AccountIDs": [],
"RatingPlanIDs": ["RPL_1"],
"ResourceIDs": ["ResGroup1"],
"StatIDs": ["Stat1"],
"Weight": 10
}],
"Blocker": false,
"Weight": 10
},
"error": null
}

View File

@@ -1,139 +0,0 @@
6. Tariff Plan Management
=========================
6.1 Create TariffPlan
---------------------
6.2 Assign TariffPlan
---------------------
6.3 Calculate Cost
------------------
Cost simulator calculates call cost (sum of ConnectFee and Cost fields) for a given pair of source(subject) and destination accounts for a specific time interval. This request can provide Pre Call Cost.
:Hint:
cgr> cost Tenant="cgrates.org" Category="call" Subject="1003" AnswerTime="2014-08-04T13:00:00Z" Destination="1002" Usage="1m25s"
*Request*
::
{
"method": "APIerSv1.GetCost",
"params": [{
"Tenant": "cgrates.org",
"Category": "call",
"Subject": "1003",
"AnswerTime": "2014-08-04T13:00:00Z",
"Destination": "1002",
"Usage": "1m25s"
}],
"id": 7
}
*Response*
::
{
"id": 7,
"result": {
"CGRID": "",
"RunID": "",
"StartTime": "2014-08-04T13:00:00Z",
"Usage": 90000000000,
"Cost": 0.25,
"Charges": [{
"RatingID": "81ca386",
"Increments": [{
"Usage": 60000000000,
"Cost": 0.2,
"AccountingID": "",
"CompressFactor": 1
}],
"CompressFactor": 1
}, {
"RatingID": "2ff21f2",
"Increments": [{
"Usage": 30000000000,
"Cost": 0.05,
"AccountingID": "",
"CompressFactor": 1
}],
"CompressFactor": 1
}],
"AccountSummary": null,
"Rating": {
"2ff21f2": {
"ConnectFee": 0.4,
"RoundingMethod": "*up",
"RoundingDecimals": 4,
"MaxCost": 0,
"MaxCostStrategy": "",
"TimingID": "998f4c1",
"RatesID": "7977f71",
"RatingFiltersID": "5165642"
},
"81ca386": {
"ConnectFee": 0.4,
"RoundingMethod": "*up",
"RoundingDecimals": 4,
"MaxCost": 0,
"MaxCostStrategy": "",
"TimingID": "998f4c1",
"RatesID": "e630781",
"RatingFiltersID": "5165642"
}
},
"Accounting": {},
"RatingFilters": {
"5165642": {
"DestinationID": "DST_1002",
"DestinationPrefix": "1002",
"RatingPlanID": "RP_RETAIL2",
"Subject": "*out:cgrates.org:call:*any"
}
},
"Rates": {
"7977f71": [{
"GroupIntervalStart": 0,
"Value": 0.2,
"RateIncrement": 60000000000,
"RateUnit": 60000000000
}, {
"GroupIntervalStart": 60000000000,
"Value": 0.1,
"RateIncrement": 30000000000,
"RateUnit": 60000000000
}],
"e630781": [{
"GroupIntervalStart": 0,
"Value": 0.2,
"RateIncrement": 60000000000,
"RateUnit": 60000000000
}, {
"GroupIntervalStart": 60000000000,
"Value": 0.1,
"RateIncrement": 30000000000,
"RateUnit": 60000000000
}]
},
"Timings": {
"998f4c1": {
"Years": [],
"Months": [],
"MonthDays": [],
"WeekDays": [1, 2, 3, 4, 5],
"StartTime": "08:00:00"
}
}
},
"error": null
}
Make Test Call
##############
:Hint:
initiate test call from account 1003 to 1002

View File

@@ -6,7 +6,7 @@ ResourceS
**ResourceS** is a standalone subsystem part of the **CGRateS** infrastructure, designed to allocate virtual resources for the generic *Events* (hashmaps) it receives.
Both receiving of *Events* as well as operational commands on the virtual resources is performed via a complete set of :ref:`CGRateS RPC APIs<remote-management>`.
Both receiving of *Events* as well as operational commands on the virtual resources is performed via a complete set of `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_.
Due it's real-time nature, **ResourceS** are designed towards high throughput being able to process thousands of *Events* per second. This is doable since each *Resource* is a very light object, held in memory and eventually backed up in *DataDB*.
@@ -46,7 +46,7 @@ nested_fields
ResourceProfile
^^^^^^^^^^^^^^^
The **ResourceProfile** is the configuration of a *Resource*. This will be performed over :ref:`CGRateS RPC APIs<remote-management>` or *.csv* files. A profile is comprised out of the following parameters:
The **ResourceProfile** is the configuration of a *Resource*. This will be performed over `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_ or *.csv* files. A profile is comprised out of the following parameters:
Tenant
The tenant on the platform (one can see the tenant as partition ID).

View File

@@ -1,3 +1,5 @@
.. _schedulers:
SchedulerS
==========

View File

@@ -4,7 +4,7 @@ SessionS
========
**SessionS** is a standalone subsystem within **CGRateS** responsible to manage virtual sessions based on events received. It is accessed via :ref:`CGRateS RPC APIs<remote-management>`.
**SessionS** is a standalone subsystem within **CGRateS** responsible to manage virtual sessions based on events received. It is accessed via `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_.
Parameters

View File

@@ -1,10 +1,12 @@
.. _stats:
StatS
=====
**StatS** is a standalone subsystem part of the **CGRateS** infrastructure, designed to aggregate and calculate statistical metrics for the generic *Events* (hashmaps) it receives.
Both receiving of *Events* as well as *Metrics* displaying is performed via a complete set of :ref:`CGRateS RPC APIs<remote-management>`.
Both receiving of *Events* as well as *Metrics* displaying is performed via a complete set of `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_.
Due it's real-time nature, **StatS** are designed towards high throughput being able to process thousands of *Events* per second. This is doable since each *StatQueue* is a very light object, held in memory and eventually backed up in *DataDB*.

View File

@@ -1,3 +1,5 @@
.. _stordb:
StorDB
======

View File

@@ -10,7 +10,7 @@ SupplierS
=========
**SupplierS** is a standalone subsystem within **CGRateS** responsible to compute a list of suppliers which can be used for a specific event received to process. It is accessed via :ref:`CGRateS RPC APIs<remote-management>`.
**SupplierS** is a standalone subsystem within **CGRateS** responsible to compute a list of suppliers which can be used for a specific event received to process. It is accessed via `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_.
As most of the other subsystems, it is performance oriented, stored inside *DataDB* but cached inside the *cgr-engine* process.
Caching can be done dynamically/on-demand or at start-time/precached and it is configurable within *cache* section in the :ref:`JSON configuration <configuration>`.

View File

@@ -1,883 +0,0 @@
4.2. Tariff Plans
=================
Major concept within CGRateS architecture, implement mechanisms to load rating as well as account data into CGRateS.
For importing the data into CGRateS database(s) we are using **csv** *files*.
The import process can be started as many times it is desired with one ore more csv files
and the existing values are overwritten.
.. important:: If **-flushdb** option is used when importing data with cgr-loader,
then the database **is cleaned** before importing.
For more details see the **cgr-loader** tool from the tutorial chapter.
The rest of this section we will describe the content of every csv file.
4.2.1. Destinations
~~~~~~~~~~~~~~~~~~~
The destinations are binding together various prefixes / caller ids to define a
logical destination group. A prefix can appear in multiple destination groups.
::
"Destinations.csv" - csv
"tp_destinations" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/Destinations.csv
:header-rows: 1
[0] - Id:
Destination Id, a string by which this destination will be referenced in other places by.
[1] - Prefix:
Prefix(es) attached to this destination.
The prefix or caller id to be added to the specified destination.
4.2.2. Timings
~~~~~~~~~~~~~~
Holds time related definitions.
Describes the time periods that have different rates attached to them.
::
"Timings.csv" - csv
"tp_timings" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/Timings.csv
:header-rows: 1
[0] - Tag:
String by which this timing will be referenced in other places by.
[1] - Years:
Integers separated by semicolons (;) specifying the years for this time period.
**\*any** in case of always.
[2] - Months:
Integers from 1=January to 12=December separated by semicolons (;) specifying the months for this time period.
**\*any** in case of always (equivalent to 1;2;3;4;5;6;7;8;9;10;11;12).
[3] - MonthDays:
Integers from 1 to 31 separated by semicolons (;) specifying the month days for this time period.
**\*any** in case of always.
[4] - WeekDays:
Integers from 1=Monday to 7=Sunday separated by semicolons (;) specifying the week days for this time period.
**\*any** in case of always.
[5] - Time:
The start time for this time period.
If you set it to **\*asap** (was **\*now**) it will be replaced with the time of the data importing.
4.2.3. Rates
~~~~~~~~~~~~
Defines price groups for various destinations which will be associated to
various timings.
::
"Rates.csv" - csv
"tp_rates" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/Rates.csv
:header-rows: 1
[0] - Id:
Rate Id, a string by which this *rate* will be referenced in other places by.
[1] - ConnectFee:
ConnectFee applied once the call is answered.
The price to be charged once at the beginning of the call to the specified
destination.
[2] - Rate:
Number of billing units this rate applies to.
The price for the billing unit expressed in cents.
[3] - RateUnit:
The billing unit expressed in seconds.
[4] - RateIncrement:
This rate will apply in increments of duration.
The time gap for the rate
[5] - GroupIntervalStart:
When the rate starts
.. seealso:: Rateincrement and GroupIntervalStart are when the calls has
different rates in the timeframe. For example, the first 30 seconds of the
calls has a rate of €0.1 and after that €0.2. The rate for this will the same
TAG with two RateIncrements
4.2.4. Destination Rates
~~~~~~~~~~~~~~~~~~~~~~~
Attach rates to destinations.
::
"DestinationRates.csv" - csv
"tp_destination_rates" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/DestinationRates.csv
:header-rows: 1
[0] - Id:
tbd
[1] - DestinationId:
tbd
[2] - RatesTag:
tbd
[3] - RoundingMethod:
tbd
[4] - RoundingDecimals:
tbd
[5] - MaxCost:
tbd
[6] - MaxCostStrategy:
tbd
4.2.5. Rating Plans
~~~~~~~~~~~~~~~~~~~
The *rating plan* makes the links between **Rating Profiles**, **Timings** and **Destination Rates** so each of them can be
described once and various combinations are made possible.
::
"RatingPlans.csv" - csv
"tp_rating_plans" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/RatingPlans.csv
:header-rows: 1
[0] - Id:
A string by which this *rating plan* will be referenced in other places by.
[1] - DestinationRatesId:
The rating id/tag described in the **Destination rates** file. (*DestinationRates.csv* - **Id**)
[2] - TimingTag:
The timing tag described in the **Timings** file. (*Timings.csv* - **Tag**)
[3] - Weight:
If multiple timings cab be applied to a call the one with the lower weight
wins. An example here can be the Christmas day: we can have a special timing
for this day but the regular day of the week timing can also be applied to
this day. The weight will differentiate between the two timings.
4.2.6. Rating profiles
~~~~~~~~~~~~~~~~~~~~~~
The *rating profile* **describes** the prices to be applied for various calls to
various destinations in various time frames. When a call is made the CGRateS
system will locate the rates to be applied to the call using the rating profiles.
::
"RatingProfiles.csv" - csv
"tp_rating_profiles" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/RatingProfiles.csv
:header-rows: 1
[0] - Direction:
Can be **\*in** or **\*out** for the INBOUND and OUTBOUND calls.
[1] - Tenant:
Used to distinguish between carriers if more than one share the same database in the CGRates system.
[2] - Category:
Type of record specifies the kind of transmission this rate profile applies to.
[3] - Subject:
The client/user for who this profile is detailing the rates.
[4] - ActivationTime:
Multiple rates timings/prices can be created for one profile with different
activation times. When a call is made the appropriate profile(s) will be
used to rate the call. So future prices can be defined here and the
activation time can be set as appropriate.
[5] - RatingPlanId:
The rating plan id/tag described in the **Rating Plans** file. (*RatingPlans.csv* - **Id**)
This specifies the profile to be used in case the call destination.
[6] - RatesFallbackSubject:
This specifies another profile to be used in case the call destination will
not be found in the current profile. The same tenant, tor and direction will
be used.
[7] - CdrStatQueueIds:
The cdr stats id described in the **Cdr Stats** file. (*CdrStats.csv* - **Id**)
Stat Queue associated with this account.
4.2.7. Account actions
~~~~~~~~~~~~~~~~~~~~~~
Describes the actions to be applied to the clients/users accounts. There are two
kinds of actions: timed and triggered. For the timed actions there is a
scheduler application that reads them from the database and executes them at the
appropriate timings. The triggered actions are executed when the specified
balance counters reach certain thresholds.
The accounts hold the various balances and counters to activate the triggered
actions for each the client.
Balance types are: MONETARY, SMS, INTERNET, INTERNET_TIME, MINUTES.
::
"AccountActions.csv" - csv
"tp_account_actions" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/AccountActions.csv
:header-rows: 1
[0] - Tenant:
Used to distinguish between carriers if more than one share the same
database in the CGRates system.
[1] - Account:
The identifier for the user's account.
[2] - Direction:
Can be **\*in** or **\*out** for the INBOUND and OUTBOUND calls.
[3] - ActionPlanId:
The action plan id/tag described in the **Action plans** file. (*ActionPlans.csv* - **Id**)
Forwards to a timed action group that will be used on this account.
[4] - ActionTriggersId:
The action trigger id/tag described in the **Action triggers** file. (*ActionTriggers.csv* - **Tag**)
Forwards to a triggered action group that will be applied to this account.
[5] - AllowNegative:
TBD
[6] - Disabled:
TBD
4.2.8 Action triggers
~~~~~~~~~~~~~~~~~~~~~~
For each account there are counters that record the activity on various
balances. Action triggers allow when a counter reaches a threshold to activate a
group of actions. After the execution the action trigger is marked as used and
will no longer be evaluated until the triggers are reset. See actions for action
trigger resetting.
::
"ActionTriggers.csv" - csv
"tp_action_triggers" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/ActionTriggers.csv
:header-rows: 1
[0] - Tag:
A string by which this action trigger will be referenced in other places by.
[1] - UniqueID:
Unique id for the trigger in multiple ActionTriggers
[2] - ThresholdType:
The threshold type. Can have one of the following:
+ **\*min_counter**: Fire when counter is less than ThresholdValue
+ **\*max_counter**: Fire when counter is greater than ThresholdValue
+ **\*min_balance**: Fire when balance is less than ThresholdValue
+ **\*max_balance**: Fire when balances is greater than ThresholdValue
+ **\*min_asr**: Fire when ASR(Average success Ratio) is less than ThresholdValue
+ **\*max_asr**: Fire when ASR is greater than ThresholdValue
+ **\*min_acd**: Fire when ACD(Average call Duration) is less than ThresholdValue
+ **\*max_acd**: Fire when ACD is greater than ThresholdValue
+ **\*min_acc**: Fire when ACC(Average call cost) is less than ThresholdValue
+ **\*max_acc**: Fire when ACC is greater than ThresholdValue
+ **\*min_tcc**: Fire when TCC(Total call cost) is less than ThresholdValue
+ **\*max_tcc**: Fire when TCC is greater than ThresholdValue
+ **\*min_tcd**: fire when TCD(total call duration) is less than thresholdvalue
+ **\*max_tcd**: fire when TCD is greater than thresholdvalue
+ **\*min_pdd**: Fire when PDD(Post Dial Delay) is less than ThresholdValue
+ **\*max_pdd**: Fire when PDD is greater than ThresholdValue
[3] - ThresholdValue:
The value of the balance counter that will trigger this action.
[4] - Recurrent(Boolean):
In case of trigger we can fire recurrent while it's active, or only the
first time.
[5] - MinSleep:
When Threshold is triggered we can sleep for the time specified.
[6] - ExpiryTime
TBD
[7] - ActivationTime
TBD
[8] - BalanceTag:
Specifies the balance counter by which this action will be triggered.
Can be:
+ **MONETARY**
+ **SMS**
+ **INTERNET**
+ **INTERNET_TIME**
+ **MINUTES**
[9] - BalanceType:
Specifies the balance type for this action:
+ **\*voice**: units of call minutes
+ **\*sms**: units of SMS
+ **\*data**: units of data
+ **\*monetary**: units of money
[10] - BalanceDirections:
Can be **\*in** or **\*out** for the INBOUND and OUTBOUND calls.
[11] - BalanceCategories:
Category of the call/trigger
[12] - BalanceDestinationIds:
The destination id/tag described in the **Destinations** file. (*Destinations.csv* - **Id**) - rinor: need verification
Destination of the call/trigger
[13] - BalanceRatingSubject:
TBD
[14] - BalanceSharedGroup:
Shared Group of the call/trigger
[15] - BalanceExpiryTime:
TBD
[16] - BalanceTimingIds:
TBD
[17] - BalanceWeight:
TBD
[18] - BalanceBlocker
TBD
[19] - BalanceDisabled:
TBD
[20] - StatsMinQueuedItems:
Min of items that need to have a queue to reach this Trigger.
Trigger actions only if this number is hit (stats only).
[21] - ActionsId:
The actions id/tag described in the **Actions** file. (*Actions.csv* - **ActionsId**)
Forwards to an action group to be executed when the threshold is reached.
[22] - Weight:
Specifies the order for these triggers to be evaluated. If there are
multiple triggers are fired in the same time the ones with the lower weight
will be executed first.
4.2.9. Action Plans
~~~~~~~~~~~~~~~~~~~
TBD
::
"ActionPlans.csv" - csv
"tp_action_plans" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/ActionPlans.csv
:header-rows: 1
[0] - Id:
A string by which this action timing will be referenced in other places by.
[1] - ActionsId:
Forwards to an action group to be executed when the timing is right.
[2] - TimingId:
A timing (one time or recurrent) at which the action group will be executed
[3] - Weight:
Specifies the order for these timings to be evaluated. If there are multiple
action timings set to be execute on the same time the ones with the lower
weight will be executed first.
4.2.10. Actions
~~~~~~~~~~~~~~
TBD
::
"Actions.csv" - csv
"tp_actions" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/Actions.csv
:header-rows: 1
[0] - ActionsId:
A string by which this action will be referenced in other places by.
[1] - Action:
The action type. Can have one of the following:
+ **\*allow_negative**: Allow to the account to have negative balance
+ **\*http_post**: Send a http request to the following url
+ **\*http_post_async**: Send a http request to the following url Asynchronous
+ **\*cdrlog**: Log the current action in the storeDB
+ **\*debit**: Debit account balance.
+ **\*deny_negative**: Deny to the account to have negative balance
+ **\*disable_account**: Disable account in the platform
+ **\*enable_account**: Enable account in the platform
+ **\*log**: Logs the other action values (for debugging purposes).
+ **\*mail_async**: Send a email to the direction
+ **\*reset_account**: Sets all counters to 0
+ **\*reset_counter**: Sets the counter for the BalanceTag to 0
+ **\*reset_counters**: Sets *all* the counters for the BalanceTag to 0
+ **\*reset_triggers**: reset all the triggers for this account
+ **\*set_recurrent**: (pending)
+ **\*topup**: Add account balance. If the specific balance is not defined, define it (example: minutes per destination).
+ **\*topup_reset**: Add account balance. If previous balance found of the same type, reset it before adding.
+ **\*unset_recurrent**: (pending)
+ **\*unlimited**: (pending)
[2] - ExtraParameters:
In Extra Parameter field you can define an argument for the action. In case
of http_post Action, extraParameter will be the url action. In case of
mail_async the email that you want to receive.
[3] - Filter
TBD
[4] - BalanceId:
The balance on which the action will operate
[5] - BalanceType:
Specifies the balance type for this action:
+ **\*voice**: units of call minutes
+ **\*sms**: units of SMS
+ **\*data**: units of data
+ **\*monetary**: units of money
[6] - Directions:
Can be **\*in** or **\*out** for the INBOUND and OUTBOUND calls.
[7] - Categories:
TBD
[8] - DestinationIds:
The destination id/tag described in the **Destinations** file. (*Destinations.csv* - Id)
This field is used only if the BalanceId is MINUTES. Specifies the
destination of the minutes to be operated.
[9] - RatingSubject:
The ratingSubject of the Actions
[10] - SharedGroup:
In case of the account uses any shared group for the balances.
[11] - ExpiryTime:
TBD
[12] - TimingIds:
Timming tag when the action can be executed. Default ALL.
[13] - Units:
Number of units for decrease the balance. Only use if BalanceType is voice.
[14] - BalanceWeight:
TBD
[15] - BalanceBlocker
TBD
[16] - BalanceDisabled:
TBD
[17] - Weight:
If there are multiple actions in a group, they will be executed in the order
of their weight (**smaller** first).
4.2.11. Derived Chargers
~~~~~~~~~~~~~~~~~~~~~~~~~
For each call we can bill more than one time, for that we need to use the
following options:
::
"DerivedChargers.csv" - csv
"tp_derived_chargers" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/DerivedChargers.csv
:header-rows: 1
In derived charges we have 2 different kind of options, **FILTERS** and **ACTIONS** :
**Filters**: With the following fields we filter the calls that need to run a extra
billing parameter.
[0] - Direction:
TBD
[1] - Tenant:
TBD
[2] - Category:
TBD
[3] - Account:
TBD
[4] - Subject:
TBD
[5] - DestinationIds:
TBD
**Actions**: In case of the filter options match, platform creates extra runid with
the fields that we want to modify.
[6] - RunId:
TBD
[7] - RunFilter:
TBD
[8] - ReqTypeField:
TBD
[9] - DirectionField:
TBD
[10] - TenantField:
TBD
[11] - CategoryField:
TBD
[12] - AccountField:
TBD
[13] - SubjectField:
TBD
[14] - DestinationField:
TBD
[15] - SetupTimeField:
TBD
[16] - PddField:
TBD
[17] - AnswerTimeField:
TBD
[18] - UsageField:
TBD
[19] - SupplierField:
TBD
[20] - DisconnectCause:
TBD
[21] - RatedField:
TBD
[22] - CostField:
TBD
In the example, all the calls with direction=out, tenant=cgrates.org,
category="call" and account and subject equal 1001. Will be created a new cdr in
the table *rated_cdrs* with the runID derived_run1, and the subject 1002.
This feature it's useful in the case that you want to rated the calls 2 times,
for example rated for different tenants or resellers.
4.2.12. CDR Stats
~~~~~~~~~~~~~~~~~~
CDR Stats enables some realtime statistics in your platform for multiple
purposes, you can read more, see :ref:`cdrstats-main`
::
"CdrStats.csv" - csv
"tp_cdr_stats" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/CdrStats.csv
:header-rows: 1
[0] - Id:
Tag name for the Queue id
[1] - QueueLength:
Maximum number of calls in this queue
[2] - TimeWindow:
Window frame to store the calls
[3] - SaveInterval:
Each interval queue stats will save in the stordb
[4] - Metric:
Type of metric see :ref:`cdrstats-metrics`
[5] - SetupInterval:
TBD
[6] - ToR:
TBD
[7] - CdrHost
TBD
[8] - CdrSource:
TBD
[9] - ReqType:
Filter by reqtype
[10] - Direction:
TBD
[11] - Tenant:
Used to distinguish between carriers if more than one share the same
database in the CGRates system.
[12] - Category:
Type of record specifies the kind of transmission this rate profile applies
to.
[13] - Account:
The identifier for the user's account.
[14] - Subject:
The client/user for who this profile is detailing the rates.
[15] - DestinationIds:
Filter only by destinations prefix. Can be multiple separated with **;**
[16] - PddInterval:
TBD
[17] - UsageInterval:
TBD
[18] - Supplier:
TBD
[19] - DisconnectCause:
TBD
[20] - RunIds:
TBD
[21] - RatedAccount:
Filter by rated account
[22] - RatedSubject:
Filter by rated subject
[23] - CostInterval:
Filter by cost
[24] - ActionTriggers:
ActionTriggers associated with this queue
4.2.13. Shared groups
~~~~~~~~~~~~~~~~~~~~~
TBD
::
"SharedGroups.csv" - csv
"tp_shared_groups" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/SharedGroups.csv
:header-rows: 1
[0] - Id:
TBD
[1] - Account:
TBD
[2] - Strategy:
TBD
[3] - RatingSubject:
TBD
4.2.14. LCR rules
~~~~~~~~~~~~~~~~~
TBD
::
"LcrRules.csv" - csv
"tp_lcr_rules" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/LcrRules.csv
:header-rows: 1
[0] - Direction:
TBD
[1] - Tenant:
TBD
[2] - Category:
TBD
[3] - Account:
TBD
[4] - Subject:
TBD
[5] - DestinationTag:
TBD
[6] - RpCategory:
TBD
[7] - Strategy:
TBD
[8] - StrategyParams:
TBD
[9] - ActivationTime:
TBD
[10] - Weight:
TBD
4.2.15. Users
~~~~~~~~~~~~~
TBD
::
"Users.csv" - csv
"tp_users" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/Users.csv
:header-rows: 1
[0] - Tenant:
TBD
[1] - UserName:
TBD
[2] - Masked:
TBD
[3] - AttributeName:
TBD
[4] - AttributeValue:
TBD
[5] - Weight:
TBD
4.2.16. Aliases
~~~~~~~~~~~~~~~
TBD
::
"Aliases.csv" - csv
"tp_aliases" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/Aliases.csv
:header-rows: 1
[0] - Direction:
TBD
[1] - Tenant:
TBD
[2] - Category:
TBD
[3] - Account:
TBD
[4] - Subject:
TBD
[5] - DestinationId:
TBD
[6] - Context:
TBD
[7] - Target:
TBD
[8] - Original:
TBD
[9] - Alias:
TBD
[10] - Weight:
TBD
4.2.17. Resource Limits
~~~~~~~~~~~~~~~~~~~~~~~
TBD
::
"Resources.csv" - csv
"tp_resources" - stor_db
.. csv-table::
:file: ../data/tariffplans/tutorial/ResourceLimits.csv
:header-rows: 1
[0] - Tag
TBD
[1] - Type
TBD
[2] - Element
TBD
[3] - Values
TBD
[4] - ActivationTime
TBD
[5] - Weight
TBD
[6] - Limit
TBD
[7] - ActionTriggerIds
TBD

View File

@@ -1,3 +1,5 @@
.. _tariffplan:
TariffPlans
===========
@@ -14,72 +16,4 @@ Due to complex data definition we have split information necessary on each load
Each individual CSV file can have any number of rows starting with comment character (#) which will be ignored on processing.
Depending on CGRateS subsystem, following files are required:
Rating
~~~~~~
.. toctree::
:maxdepth: 2
csv_tptimings
.. toctree::
:maxdepth: 2
csv_tpdestinations
.. toctree::
:maxdepth: 2
csv_tprates
.. toctree::
:maxdepth: 2
csv_tpdestinationrates
.. toctree::
:maxdepth: 2
csv_tpdestratetimings
.. toctree::
:maxdepth: 2
csv_tpratingprofiles
Accounting
~~~~~~~~~~
.. toctree::
:maxdepth: 2
csv_tptimings
.. toctree::
:maxdepth: 2
csv_tpdestinations
.. toctree::
:maxdepth: 2
csv_tpactions
.. toctree::
:maxdepth: 2
csv_tpactiontimings
.. toctree::
:maxdepth: 2
csv_tpactiontriggers
.. toctree::
:maxdepth: 2
csv_tpaccountactions
Examples of TariffPlans as CSVs can be found on the `GitHub repository <https://github.com/cgrates/cgrates/tree/v0.10/data/tariffplans>`_ .

View File

@@ -4,7 +4,7 @@ ThresholdS
==========
**ThresholdS** is a standalone subsystem within **CGRateS** responsible to execute a list of *Actions* for a specific event received to process. It is accessed via :ref:`CGRateS RPC APIs<remote-management>`.
**ThresholdS** is a standalone subsystem within **CGRateS** responsible to execute a list of *Actions* for a specific event received to process. It is accessed via `CGRateS RPC APIs <https://godoc.org/github.com/cgrates/cgrates/apier/>`_.
As most of the other subsystems, it is performance oriented, stored inside *DataDB* but cached inside the *cgr-engine* process.
Caching can be done dynamically/on-demand or at start-time/precached and it is configurable within *cache* section in the :ref:`JSON configuration <configuration>`.

View File

@@ -12,5 +12,5 @@ In these tutorials we exemplify a few cases of integration between FreeSWITCH_ a
tut_freeswitch_json
tut_cgrates_usage
.. _FreeSWITCH: http://www.freeswitch.org/
.. _FreeSWITCH: https://freeswitch.com/

View File

@@ -1,79 +0,0 @@
FreeSWITCH_ generating *.csv* CDRs
==================================
Scenario
--------
- FreeSWITCH with *vanilla* configuration, minimal modifications to fit our needs.
- Modified following users (with configs in *etc/freeswitch/directory/default*): 1001-prepaid, 1002-postpaid, 1003-pseudoprepaid, 1004-rated.
- Have added inside default dialplan CGR own extensions just before routing towards users (*etc/freeswitch/dialplan/default.xml*).
- FreeSWITCH configured to generate default *.csv* CDRs, modified example template to add cgr_reqtype from user variables (*etc/freeswitch/autoload_configs/cdr_csv.conf.xml*).
- **CGRateS** with following components:
- CGR-SM started as prepaid controller, with debits taking place at 5s intervals.
- CGR-CDRC component importing FreeSWITCH_ generated *.csv* CDRs into CGR and moving the processed *.csv* files to */tmp* folder.
- CGR-Mediator compoenent attaching costs to the raw CDRs from CGR-CDRC inside CGR StorDB.
- CGR-CDRE exporting mediated CDRs from CGR StorDB (export path: */tmp*).
- CGR-History component keeping the archive of the rates modifications (path browsable with git client at */tmp/cgr_history*).
Starting FreeSWITCH_ with custom configuration
----------------------------------------------
::
/usr/share/cgrates/tutorials/fs_csv/freeswitch/etc/init.d/freeswitch start
To verify that FreeSWITCH_ is running we run the console command:
::
fs_cli -x status
Starting **CGRateS** with custom configuration
----------------------------------------------
::
/usr/share/cgrates/tutorials/fs_csv/cgrates/etc/init.d/cgrates start
Check that cgrates is running
::
cgr-console status
CDR processing
--------------
For every call FreeSWITCH_ will generate CDR records within the *Master.csv* file.
In order to avoid double-processing we will use the rotate mechanism built in FreeSWITCH_.
Once rotated, we will move the resulted files inside the path considered by **CGRateS** *CDRC* component as inbound.
These steps are automated in a script provided in the */usr/share/cgrates/scripts* location:
::
/usr/share/cgrates/scripts/freeswitch_cdr_csv_rotate.sh
On each rotate CGR-CDRC component will be informed via *inotify* subsystem and will instantly process the CDR file. The records end up in **CGRateS**/StorDB inside *cdrs_primary* table via CGR-CDRS. As soon as the CDR will hit CDRS component, mediation will occur, either considering the costs calculated in case of prepaid and postpaid calls out of *cost_details* table or query it's own one from rater in case of *pseudoprepaid* and *rated* CDRs.
Once the CDRs are mediated, can be exported as *.csv* format again via remote command offered by *cgr-console* tool:
::
cgr-console 'cdrs_export CdrFormat="csv" ExportDir="/tmp"'
**CGRateS** Usage
-----------------
Since it is common to most of the tutorials, the example for **CGRateS** usage is provided in a separate page `here <http://cgrates.readthedocs.org/en/latest/tut_cgrates_usage.html>`_
.. _FreeSWITCH: http://www.freeswitch.org/
.. _Jitsi: http://www.jitsi.org/

View File

@@ -29,4 +29,4 @@ We will install FreeSWITCH_ via following commands:
Once installed, we will proceed with loading the configuration out of specific tutorial cases bellow.
.. _FreeSWITCH: http://www.freeswitch.org/
.. _FreeSWITCH: https://freeswitch.com/

View File

@@ -62,5 +62,5 @@ At the end of each call FreeSWITCH_ will issue a http post with the CDR. This wi
Since it is common to most of the tutorials, the example for **CGRateS** usage is provided in a separate page `here <http://cgrates.readthedocs.org/en/latest/tut_cgrates_usage.html>`_
.. _FreeSWITCH: http://www.freeswitch.org/
.. _Jitsi: http://www.jitsi.org/
.. _FreeSWITCH: https://freeswitch.com/
.. _Jitsi: https://jitsi.org/

View File

@@ -1,6 +1,6 @@
SIP UA - Jitsi_
---------------
On our ubuntu desktop host, we have installed Jitsi_ to be used as SIP UA, out of stable provided packages on `Jitsi download <https://jitsi.org/Main/Download>`_ and had Jitsi_ configured with 4 accounts: 1001/CGRateS.org, 1002/CGRateS.org, 1003/CGRateS.org and 1004/CGRateS.org.
On our ubuntu desktop host, we have installed Jitsi_ to be used as SIP UA, out of stable provided packages on `Jitsi download <https://jitsi.org/downloads/>`_ and had Jitsi_ configured with 4 accounts: 1001/CGRateS.org, 1002/CGRateS.org, 1003/CGRateS.org and 1004/CGRateS.org.
.. _Jitsi: http://www.jitsi.org/
.. _Jitsi: https://jitsi.org/

View File

@@ -12,6 +12,6 @@ In these tutorials we exemplify a few cases of integration between Kamailio_ and
tut_kamailio_evapi
tut_cgrates_usage
.. _Kamailio: http://www.kamailio.org/
.. _Kamailio: https://www.kamailio.org/w/
.. _CGRateS: http://www.cgrates.org/

View File

@@ -56,4 +56,4 @@ At the end of each call Kamailio_ will generate an CDR event via *evapi* and thi
Since it is common to most of the tutorials, the example for **CGRateS** usage is provided in a separate page `here <http://cgrates.readthedocs.org/en/latest/tut_cgrates_usage.html>`_
.. _Kamailio: http://www.kamailio.org/
.. _Kamailio: https://www.kamailio.org/w/

View File

@@ -23,4 +23,4 @@ We got Kamailio_ installed via following commands:
Once installed we proceed with loading the configuration out of specific tutorial cases bellow.
.. _Kamailio: http://www.kamailio.org/
.. _Kamailio: https://www.kamailio.org/w/

View File

@@ -12,6 +12,6 @@ In these tutorials we exemplify a few cases of integration between OpenSIPS_ and
tut_opensips_event
tut_cgrates_usage
.. _OpenSIPS: http://www.opensips.org/
.. _OpenSIPS: https://opensips.org/
.. _CGRateS: http://www.cgrates.org/

View File

@@ -57,4 +57,4 @@ At the end of each call OpenSIPS_ will generate an CDR event and due to automati
Since it is common to most of the tutorials, the example for **CGRateS** usage is provided in a separate page `here <http://cgrates.readthedocs.org/en/latest/tut_cgrates_usage.html>`_
.. _OpenSIPS: http://www.opensips.org/
.. _OpenSIPS: https://opensips.org/

View File

@@ -22,4 +22,4 @@ We got OpenSIPS_ installed via following commands:
Once installed we proceed with loading the configuration out of specific tutorial cases bellow.
.. _OpenSIPS: http://www.opensips.org/
.. _OpenSIPS: https://opensips.org/