Adding opensips training tariff plans

This commit is contained in:
DanB
2016-08-03 21:48:32 +02:00
parent 69930adb10
commit 182c13a8af
15 changed files with 59 additions and 50 deletions

View File

@@ -1,31 +0,0 @@
FROM debian:wheezy
MAINTAINER Radu Fericean, rif@cgrates.org
RUN apt-get -y update
# set mysql password
RUN echo 'mysql-server mysql-server/root_password password CGRateS.org' | debconf-set-selections && echo 'mysql-server mysql-server/root_password_again password CGRateS.org' | debconf-set-selections
# install dependencies
RUN apt-get update && apt-get -y install redis-server mysql-server git sudo wget libcurl3-gnutls libgssapi-krb5-2 libldap-2.4-2 librtmp0 libssh2-1 ca-certificates libsasl2-2 libkrb5support0 libkrb5-3 libkeyutils1 libk5crypto3 openssl libssl1.0.0 libjson0 wget adduser libcurl3-gnutls
# add cgrates user
RUN useradd -c CGRateS -d /var/run/cgrates -s /bin/false -r cgrates
# install cgrates
RUN URL='http://www.cgrates.org/tmp_pkg/cgrates_0.9.1~rc6_amd64.deb'; FILE=`mktemp`; wget "$URL" -qO $FILE && dpkg -i $FILE; rm $FILE
#install opensips
RUN URL='http://cgrates.org/pkg/opensips/opensips_2.1.0-1_amd64.deb'; FILE=`mktemp`; wget "$URL" -qO $FILE && dpkg -i $FILE; rm $FILE
RUN URL='http://cgrates.org/pkg/opensips/opensips-json-module_2.1.0-1_amd64.deb'; FILE=`mktemp`; wget "$URL" -qO $FILE && dpkg -i $FILE; rm $FILE
# init mysql
cd /usr/share/cgrates/storage/mysql && ./setup_cgr_db.sh root CGRateS.org
# add etc files
COPY /opensips/etc cgrates/etc /etc
# cleanup
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

View File

@@ -1,11 +0,0 @@
Docker
=======
From the project root:
``` bash
# build the image
docker build -t osips data/docker/ospis
# create the container
docker run --rm -itv `pwd`:/root/code --name cgr osips
```

View File

@@ -1,3 +0,0 @@
[client]
user=root
password=CGRateS.org

View File

@@ -1,5 +0,0 @@
/etc/init.d/mysql start
/etc/init.d/redis-server start
bash --rcfile /root/.bashrc

View File

@@ -0,0 +1,6 @@
#Tenant,Account,ActionPlanId,ActionTriggersId,AllowNegative,Disabled
cgrates.org,101,TEST_ACCOUNT,TEST_THRESHOLDS,,
cgrates.org,102,TEST_ACCOUNT,TEST_THRESHOLDS,,
cgrates.org,103,TEST_ACCOUNT,TEST_THRESHOLDS,,
cgrates.org,104,TEST_ACCOUNT,TEST_THRESHOLDS,,
cgrates.org,105,TEST_ACCOUNT,TEST_THRESHOLDS,,
1 #Tenant Account ActionPlanId ActionTriggersId AllowNegative Disabled
2 cgrates.org 101 TEST_ACCOUNT TEST_THRESHOLDS
3 cgrates.org 102 TEST_ACCOUNT TEST_THRESHOLDS
4 cgrates.org 103 TEST_ACCOUNT TEST_THRESHOLDS
5 cgrates.org 104 TEST_ACCOUNT TEST_THRESHOLDS
6 cgrates.org 105 TEST_ACCOUNT TEST_THRESHOLDS

View File

@@ -0,0 +1,3 @@
#Id,ActionsId,TimingId,Weight
TEST_ACCOUNT,TOPUP_MONETARY_5,*asap,10
TEST_ACCOUNT,TOPUP_VOICE_200,*asap,10
1 #Id ActionsId TimingId Weight
2 TEST_ACCOUNT TOPUP_MONETARY_5 *asap 10
3 TEST_ACCOUNT TOPUP_VOICE_200 *asap 10

View File

@@ -0,0 +1,4 @@
#Tag[0],UniqueId[1],ThresholdType[2],ThresholdValue[3],Recurrent[4],MinSleep[5],ExpiryTime[6],ActivationTime[7],BalanceTag[8],BalanceType[9],BalanceDirections[10],BalanceCategories[11],BalanceDestinationIds[12],BalanceRatingSubject[13],BalanceSharedGroup[14],BalanceExpiryTime[15],BalanceTimingIds[16],BalanceWeight[17],BalanceBlocker[18],BalanceDisabled[19],StatsMinQueuedItems[20],ActionsId[21],Weight[22]
TEST_THRESHOLDS,,*min_balance,2,false,0,,,,*monetary,*out,,,,,,,,,,,LOG_WARNING,10
TEST_THRESHOLDS,,*max_balance,20,false,0,,,,*monetary,*out,,,,,,,,,,,LOG_WARNING,10
STATS_WARN,,*min_asr,35,true,1m,,,,,,,,,,,,,,,3,LOG_WARNING,10
1 #Tag[0] UniqueId[1] ThresholdType[2] ThresholdValue[3] Recurrent[4] MinSleep[5] ExpiryTime[6] ActivationTime[7] BalanceTag[8] BalanceType[9] BalanceDirections[10] BalanceCategories[11] BalanceDestinationIds[12] BalanceRatingSubject[13] BalanceSharedGroup[14] BalanceExpiryTime[15] BalanceTimingIds[16] BalanceWeight[17] BalanceBlocker[18] BalanceDisabled[19] StatsMinQueuedItems[20] ActionsId[21] Weight[22]
2 TEST_THRESHOLDS *min_balance 2 false 0 *monetary *out LOG_WARNING 10
3 TEST_THRESHOLDS *max_balance 20 false 0 *monetary *out LOG_WARNING 10
4 STATS_WARN *min_asr 35 true 1m 3 LOG_WARNING 10

View File

@@ -0,0 +1,4 @@
#ActionsId[0],Action[1],ExtraParameters[2],Filter[3],BalanceId[4],BalanceType[5],Directions[6],Categories[7],DestinationIds[8],RatingSubject[9],SharedGroup[10],ExpiryTime[11],TimingIds[12],Units[13],BalanceWeight[14],BalanceBlocker[15],BalanceDisabled[16],Weight[17]
TOPUP_MONETARY_5,*topup_reset,,,,*monetary,*out,,*any,,,*unlimited,,10,10,false,false,10
TOPUP_VOICE_200,*topup_reset,,,,*voice,*out,,DST_ON_NET,,,*unlimited,,12000,20,false,false,10
LOG_WARNING,*log,,,,,,,,,,,,,,false,false,10
1 #ActionsId[0] Action[1] ExtraParameters[2] Filter[3] BalanceId[4] BalanceType[5] Directions[6] Categories[7] DestinationIds[8] RatingSubject[9] SharedGroup[10] ExpiryTime[11] TimingIds[12] Units[13] BalanceWeight[14] BalanceBlocker[15] BalanceDisabled[16] Weight[17]
2 TOPUP_MONETARY_5 *topup_reset *monetary *out *any *unlimited 10 10 false false 10
3 TOPUP_VOICE_200 *topup_reset *voice *out DST_ON_NET *unlimited 12000 20 false false 10
4 LOG_WARNING *log false false 10

View File

@@ -0,0 +1,6 @@
#Id[0],QueueLength[1],TimeWindow[2],SaveInerval[3],Metric[4],SetupInterval[5],TOR[6],CdrHost[7],CdrSource[8],ReqType[9],Direction[10],Tenant[11],Category[12],Account[13],Subject[14],DestinationIds[15],PddInterval[16],UsageInterval[17],Supplier[18],DisconnectCause[19],RunIds[20],RatedAccount[21],RatedSubject[22],CostInterval[23],Triggers[24]
STATS_TEST,10,0,10s,ASR,,,,,,,cgrates.org,,,,,,,,,*default,,,,STATS_WARN
STATS_TEST,,,,ACD,,,,,,,,,,,,,,,,,,,,
STATS_TEST,,,,ACC,,,,,,,,,,,,,,,,,,,,
STATS_TEST,,,,TCD,,,,,,,,,,,,,,,,,,,,
STATS_TEST,,,,TCC,,,,,,,,,,,,,,,,,,,,
1 #Id[0] QueueLength[1] TimeWindow[2] SaveInerval[3] Metric[4] SetupInterval[5] TOR[6] CdrHost[7] CdrSource[8] ReqType[9] Direction[10] Tenant[11] Category[12] Account[13] Subject[14] DestinationIds[15] PddInterval[16] UsageInterval[17] Supplier[18] DisconnectCause[19] RunIds[20] RatedAccount[21] RatedSubject[22] CostInterval[23] Triggers[24]
2 STATS_TEST 10 0 10s ASR cgrates.org *default STATS_WARN
3 STATS_TEST ACD
4 STATS_TEST ACC
5 STATS_TEST TCD
6 STATS_TEST TCC

View File

@@ -0,0 +1,2 @@
#Id,DestinationId,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy
DR_ANY_1CNT,*any,RT_1CNT,*up,4,0,
1 #Id DestinationId RatesTag RoundingMethod RoundingDecimals MaxCost MaxCostStrategy
2 DR_ANY_1CNT *any RT_1CNT *up 4 0

View File

@@ -0,0 +1,3 @@
#Id,Prefix
DST_ON_NET,10
1 #Id Prefix
2 DST_ON_NET 10

View File

@@ -0,0 +1,24 @@
OpenSIPS-CGRateS integration training
=====================================
Scenario:
---------
- Simple rating scenario: any destination dialed will be charged with a setup fee of 5 cents and 1 cent per second in 1 minute increment for the first minute then in second increments.
- Cost simulation can be achieved via cost command: cgr-console 'cost Category="call" Tenant="cgrates.org" Subject="101" Destination="+4986517174963" TimeStart="2016-08-03T13:00:00Z" TimeEnd="2016-08-03T13:01:02Z"'
- Create 5 accounts (101, 102, 103, 104, 105).
- Each account will receive 2 balances:
- One *voice with 200 minutes on-net (destinations starting with 10 prefix)
- One *monetary balance with 5 EUR/USD without destination limits
- For each account we will set up 2 account triggers: one monitoring minimum balance (2 in our case) and second monitoring fraud (maximum balance) with threshold being set to 20. On thresholds being hit there will be a syslog warning
- Account checks possible via account command: cgr-console 'accounts Tenant="cgrates.org" AccountIds=["101"]'
- Create one CDRStatS queue building up ASR, ACD, ACC, TCD, TCC metrics and having action triggers monitoring minimum asr of 35% - again with syslog as warning.
- CDRStatS queue metrics possible via console command: cgr-console 'cdrstats_metrics StatsQueueId="STATS_TEST"'

View File

@@ -0,0 +1,3 @@
#Id,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart
RT_1CNT,0.05,0.01,1s,60s,0s
RT_1CNT,0,0.01,1s,1s,60s
1 #Id ConnectFee Rate RateUnit RateIncrement GroupIntervalStart
2 RT_1CNT 0.05 0.01 1s 60s 0s
3 RT_1CNT 0 0.01 1s 1s 60s

View File

@@ -0,0 +1,2 @@
#Id,DestinationRatesId,TimingTag,Weight
RP_TRAINING1,DR_ANY_1CNT,*any,10
1 #Id DestinationRatesId TimingTag Weight
2 RP_TRAINING1 DR_ANY_1CNT *any 10

View File

@@ -0,0 +1,2 @@
#Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject,CdrStatQueueIds
*out,cgrates.org,call,*any,2016-08-01T00:00:00Z,RP_TRAINING1,,
1 #Direction Tenant Category Subject ActivationTime RatingPlanId RatesFallbackSubject CdrStatQueueIds
2 *out cgrates.org call *any 2016-08-01T00:00:00Z RP_TRAINING1