mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 20:59:53 +05:00
Updating tutorial2 sample .csvs and few of the docs for installing with OpenSIPS
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
#ID[0],UniqueID[1],ThresholdType[2],ThresholdValue[3],Recurrent[4],MinSleep[5],ExpiryTime[6],ActivationTime[7],BalanceTag[8],BalanceType[9],BalanceCategories[10],BalanceDestinationIDs[11],BalanceRatingSubject[12],BalanceSharedGroup[13],BalanceExpiryTime[14],BalanceTimingIDs[15],BalanceWeight[16],BalanceBlocker[17],BalanceDisabled[18],ActionsID[19],Weight[20]
|
||||
|
||||
# STANDARD_TRIGGERS *min_balance will call the action <TOPUP_BONUS_10SMS> when the monetary balance will go bellow 2 units
|
||||
STANDARD_TRIGGERS,,*min_balance,2,,,,,,*monetary,,,,,,,,,,TOPUP_BONUS_10SMS,10
|
||||
|
||||
# STANDARD_TRIGGERS *max_balance will call <DISABLE_ACCOUNT> action when the monetary balance will go above 100 units
|
||||
STANDARD_TRIGGERS,,*max_balance,100,,,,,,*monetary,,,,,,,,,,DISABLE_ACCOUNT,10
|
||||
|
@@ -1,11 +1,12 @@
|
||||
# Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,Path,Type,Value,Blocker,Weight
|
||||
|
||||
# CRG_RESELLER1 replaces Category->reseller1 and RequestType->*rated for *sessions and *cdrs events
|
||||
cgrates.org,ATTR_CRG_SUPPLIER1,*sessions;*cdrs,,,,*req.Category,*constant,reseller1,false,0
|
||||
cgrates.org,ATTR_CRG_SUPPLIER1,,,,,*req.RequestType,*constant,*rated,,
|
||||
|
||||
# ATTR_1001_AUTH returns the Password value for the account 1001 in context <auth>
|
||||
cgrates.org,ATTR_1001_AUTH,auth,*string:~*req.Account:1001,,,*req.Password,*constant,CGRateS.org,false,20
|
||||
|
||||
cgrates.org,ATTR_1002_AUTH,auth,*string:~*req.Account:1002,,,*req.Password,*constant,CGRateS.org,false,20
|
||||
cgrates.org,ATTR_1003_AUTH,auth,*string:~*req.Account:1003,,,*req.Password,*constant,CGRateS.org,false,20
|
||||
#Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,Path,Type,Value,Blocker,Weight
|
||||
cgrates.org,ATTR_1001,*any,*string:~*req.Account:1001,,,,,,false,10
|
||||
cgrates.org,ATTR_1001,,,,,*req.Password,*constant,CGRateS.org,,
|
||||
cgrates.org,ATTR_1001,,,,,*req.RequestType,*constant,*prepaid,,
|
||||
cgrates.org,ATTR_1001,,,,,*req.PaypalAccount,*constant,cgrates@paypal.com,,
|
||||
cgrates.org,ATTR_1001,,,,,*req.LCRProfile,*constant,premium_cli,,
|
||||
cgrates.org,ATTR_1002,*any,*string:~*req.Account:1002,,,,,,false,10
|
||||
cgrates.org,ATTR_1002,,,,,*req.Password,*constant,CGRateS.org,,
|
||||
cgrates.org,ATTR_1002,,,,,*req.RequestType,*constant,*postpaid,,
|
||||
cgrates.org,ATTR_1003,*any,*string:~*req.Account:1003,,,,,CGRateS.org,false,10
|
||||
cgrates.org,ATTR_1003,,,,,*req.Password,*constant,CGRateS.org,false,10
|
||||
cgrates.org,ATTR_1003,,,,,*req.RequestType,*constant,*pseudoprepaid,,
|
||||
|
@@ -1,8 +1,3 @@
|
||||
# Tenant,ID,FilterIDs,ActivationInterval,RunID,AttributeIDs,Weight
|
||||
|
||||
# CGR_DEFAULT is the default charger for events
|
||||
cgrates.org,CGR_DEFAULT,,,*default,*none,0
|
||||
|
||||
# CGR_RESELLER1 creates an additional CDR for calculating reseller costs
|
||||
# uses ATTR_CRG_RESELLER1 to replace Category and RequestType in events
|
||||
cgrates.org,CRG_RESELLER1,,,reseller1,ATTR_CRG_RESELLER1,1
|
||||
#Tenant,ID,FilterIDs,ActivationInterval,RunID,AttributeIDs,Weight
|
||||
cgrates.org,CHRG_DEFAULT,,,*default,*none,0
|
||||
cgrates.org,CHRG_SUPPLIER,*exists:~*req.Supplier:,,supplier,*constant:*req.RequestType:*rated;*constant:*req.Category:~*req.Supplier,0
|
||||
|
@@ -1,13 +1,19 @@
|
||||
#ID,DestinationsID,RatesID,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy
|
||||
DR_10_120C,DST_10,RT_120C,*up,4,,
|
||||
DR_10_60C,DST_10,RT_60C,*up,4,,
|
||||
DR_2030_120C,DST_2030,RT_120C,*up,4,,
|
||||
DR_20_60C,DST_20,RT_60C,*up,4,,
|
||||
DR_VOICEMAIL_FREE,DST_VOICEMAIL,RT_0,*up,4,,
|
||||
DR_1002_60C,DST_1002,RT_60C,*up,4,,
|
||||
DR_ANY_10C_CN,*any,RT_10C_CN,*up,4,,
|
||||
DR_ANY_1024_1,*any,RT_1024_1,*up,4,,
|
||||
DR_1002_10C1,DST_1002,RT_10C1,*up,4,,
|
||||
DR_10_20C1,DST_10,RT_20C1,*up,4,,
|
||||
DR_1CNT,*any,RT_1CNT,*up,4,,
|
||||
DR_10CNT,*any,RT_10CNT,*up,4,,
|
||||
|
||||
DR_DEFAULT,DST_10,RT_120_20_60,*up,5,,
|
||||
DR_DEFAULT,DST_20,RT_180_10_60,*up,5,,
|
||||
DR_DEFAULT,*any,RT_240_30_60,*up,5,,
|
||||
|
||||
DR_1001,DST_20,RT_120_10_60,*up,5,,
|
||||
|
||||
DR_SMS,DST_10,RT_5_1,*up,5,,
|
||||
DR_SMS,*any,RT_10_1,*up,5,,
|
||||
|
||||
DR_DATA,*any,RT_10_1024,*up,5,,
|
||||
|
||||
DR_SPL1,DST_10,RT_60_60,*up,5,,
|
||||
DR_SPL1,DST_20,RT_120_60,*up,5,,
|
||||
|
||||
DR_SPL2,DST_10,RT_30_60,*up,5,,
|
||||
|
||||
DR_SPECIAL_BLC,*any,RT_15_0_1,*up,5,,
|
||||
|
@@ -1,8 +1,3 @@
|
||||
#ID,Prefix
|
||||
DST_10,10
|
||||
DST_20,20
|
||||
DST_2030,20
|
||||
DST_2030,30
|
||||
DST_VOICEMAIL,voicemail
|
||||
DST_1002,1002
|
||||
DST_50,50
|
||||
|
||||
|
2
data/tariffplans/tutorial2/Filters.csv
Normal file
2
data/tariffplans/tutorial2/Filters.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
#Tenant[0],ID[1],Type[2],Element[3],Values[4],ActivationInterval[5]
|
||||
cgrates.org,FLTR_ACNT_1001_1002,*string,~*req.Account,1001;1002,2014-07-29T15:00:00Z
|
||||
|
@@ -1,29 +1,37 @@
|
||||
#ID,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart
|
||||
|
||||
# RT_120C charges 0.20 units as connect fee and 1.2 in 1 minute increment in the first minute and second increments after that
|
||||
RT_120C,0.2,1.2,1m,1m,0
|
||||
RT_120C,,1.2,1m,1s,1m
|
||||
# RT_120_20_60 charges 0.20 units as connect fee and 1.2 in 1 minute increment in the first minute and second increments after that ,,,,,
|
||||
RT_120_20_60,0.2,1.2,1m,1m,0
|
||||
RT_120_20_60,,1.2,1m,1s,1m
|
||||
|
||||
# RT_60C charges 0.1 connect fee and 0.01 units each second
|
||||
RT_60C,0.1,0.01,1s,1s,0
|
||||
# RT_180_10_60 charges 0.10 units as connect fee and 1.8 in 1 minute increment in the first minute and second increments after that ,,,,,
|
||||
RT_180_10_60,0.1,1.8,1m,1m,0
|
||||
RT_180_10_60,,1.8,1m,1s,1m
|
||||
|
||||
# RT_0 charges 0 units rounding each call per minute
|
||||
RT_0,0,0,1m,1m,0
|
||||
# RT_240_30_60 charges 0.3 units as connect fee and 2.4 in 1 minute increment in the first minute and second increments after that ,,,,,
|
||||
RT_240_30_60,0.3,2.4,1m,1m,0
|
||||
RT_240_30_60,,2.4,1m,1s,1m
|
||||
|
||||
# RT_10C_CN charges 0.1 units as connect/call fee
|
||||
RT_10C_CN,0.1,0,0,1s,0
|
||||
# RT_120_10_60 charges 0.1 units as connect fee and 1.2 in 1 minute increment ,,,,,
|
||||
RT_120_10_60,0.1,1.2,1m,1m,0
|
||||
|
||||
# RT_1024_1 will be used to charge 1 unit per every 1024 of usage in increments of 1024
|
||||
RT_1024_1,0,1,1024,1024,0
|
||||
# RT_5_1 charges 0.05 units per 1 unit of usage (SMS) ,,,,,
|
||||
RT_5_1,,0.05,1,1,0
|
||||
|
||||
# RT_10C1 charges 0.1 units of cost every 1 unit of usage
|
||||
RT_10C1,0,0.1,1,1,0
|
||||
# RT_10_1 charges 0.1 units per 1 unit of usage (SMS) ,,,,,
|
||||
RT_10_1,,0.1,1,1,0
|
||||
|
||||
# RT_20C1 charges 0.2 units of cost every 1 unit of usage
|
||||
RT_20C1,0,0.2,1,1,0
|
||||
# RT_10_1024 charges 0.1 units per 1024 units of usage in increments of 1024 units(DATA) ,,,,,
|
||||
RT_10_1024,,0.1,1024,1024,0
|
||||
|
||||
# RT_1CNT charges 0.01 units of cost for each 1s of usage
|
||||
RT_1CNT,0,0.01,1s,1s,0
|
||||
# RT_60_60 charges 0.6 per minute in second increments ,,,,,
|
||||
RT_60_60,,0.6,1m,1s,0
|
||||
|
||||
# RT_10CNT charges 0.1 units of cost for each call connected
|
||||
RT_10CNT,0.1,0,1s,1s,0
|
||||
# RT_120_60 charges 1.2 per minute in second increments ,,,,,
|
||||
RT_120_60,,1.2,1m,1s,0
|
||||
|
||||
# RT_30_60 charges 0.3 per minute in second increments ,,,,,
|
||||
RT_30_60,,0.3,1m,1s,0
|
||||
|
||||
# RT_15_0_1 charges 0.15 per call ,,,,,
|
||||
RT_15_0_1,0.15,,1s,1s,0
|
||||
|
||||
|
@@ -1,15 +1,22 @@
|
||||
#ID,DestinationRatesID,TimingID,Weight
|
||||
RP_STANDARD,DR_10_120C,PEAK,10
|
||||
RP_STANDARD,DR_10_60C,OFFPEAK_MORNING,10
|
||||
RP_STANDARD,DR_10_60C,OFFPEAK_EVENING,10
|
||||
RP_STANDARD,DR_10_60C,OFFPEAK_WEEKEND,10
|
||||
RP_STANDARD,DR_2030_120C,*any,10
|
||||
RP_STANDARD,DR_20_60C,NEW_YEAR,20
|
||||
RP_STANDARD,DR_VOICEMAIL_FREE,*any,10
|
||||
RP_1001,DR_1002_60C,*any,10
|
||||
RP_SPECIAL_BLC,DR_ANY_10C_CN,*any,10
|
||||
RP_DATA,DR_ANY_1024_1,*any,10
|
||||
RP_SMS,DR_1002_10C1,*any,10
|
||||
RP_SMS,DR_10_20C1,*any,10
|
||||
RP_1CNT,DR_1CNT,*any,0
|
||||
RP_10CNT,DR_10CNT,*any,0
|
||||
#Id,DestinationRatesId,TimingTag,Weight
|
||||
|
||||
# RP_DEFAULT definition ,,,
|
||||
RP_DEFAULT,DR_DEFAULT,*any,0
|
||||
|
||||
# RP_1001 definition ,,,
|
||||
RP_1001,DR_1001,*any,0
|
||||
|
||||
# RP_SMS definition ,,,
|
||||
RP_SMS,DR_SMS,*any,0
|
||||
|
||||
# RP_DATA definition ,,,
|
||||
RP_DATA,DR_DATA,*any,0
|
||||
|
||||
# RP_SPL1 definition ,,,
|
||||
RP_SPL1,DR_SPL1,*any,0
|
||||
|
||||
# RP_SPL2 definition ,,,
|
||||
RP_SPL2,DR_SPL2,*any,0
|
||||
|
||||
# RP_SPECIAL_BLC definition ,,,
|
||||
RP_SPECIAL_BLC,DR_SPECIAL_BLC,*any,0
|
||||
|
||||
|
@@ -1,9 +1,21 @@
|
||||
#Tenant,Category,Subject,ActivationTime,RatingPlanID,FallbackSubject
|
||||
cgrates.org,call,*any,2019-03-01T00:00:00Z,RP_STANDARD,
|
||||
cgrates.org,call,1001,2019-03-01T00:00:00Z,RP_1001,*any
|
||||
cgrates.org,call,RPF_SPECIAL_BLC,2019-03-01T00:00:00Z,RP_SPECIAL_BLC,
|
||||
cgrates.org,data,*any,2019-03-01T00:00:00Z,RP_DATA,
|
||||
cgrates.org,sms,*any,2019-03-01T00:00:00Z,RP_SMS,
|
||||
#Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject
|
||||
|
||||
# Standard rates for calls,,,,,
|
||||
cgrates.org,call,*any,2014-01-14T00:00:00Z,RP_DEFAULT,
|
||||
|
||||
# Custom rates for Subject 1001,,,,,
|
||||
cgrates.org,call,1001,2014-01-14T00:00:00Z,RP_1001,*any
|
||||
|
||||
# Default rates for data and SMS,,,,,
|
||||
cgrates.org,data,*any,2014-01-14T00:00:00Z,RP_DATA,
|
||||
cgrates.org,sms,*any,2014-01-14T00:00:00Z,RP_SMS,
|
||||
|
||||
# Supplier rates selected via CHRG_SUPPLIER or Suppliers.csv,,,,,
|
||||
cgrates.org,supplier1,*any,2014-01-14T00:00:00Z,RP_SPL1,
|
||||
cgrates.org,supplier2,*any,2014-01-14T00:00:00Z,RP_SPL2,
|
||||
|
||||
# Special rating subject for balances paying per call,,,,,
|
||||
cgrates.org,call,RPF_SPECIAL_BLC,2014-01-14T00:00:00Z,RP_SPECIAL_BLC,
|
||||
|
||||
|
||||
|
||||
# reseller1 will pay 0.1 per call, independent of duration
|
||||
cgrates.org,reseller1,*any,2019-03-01T00:00:00Z,RP_10CNT,
|
||||
|
||||
|
2
data/tariffplans/tutorial2/Resources.csv
Normal file
2
data/tariffplans/tutorial2/Resources.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],Weight[9],ThresholdIDs[10]
|
||||
cgrates.org,ResGroup1,*prefix:~*req.Account:100,2014-07-29T15:00:00Z,-1,7,,,true,,*none
|
||||
|
4
data/tariffplans/tutorial2/Stats.csv
Normal file
4
data/tariffplans/tutorial2/Stats.csv
Normal file
@@ -0,0 +1,4 @@
|
||||
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],QueueLength[4],TTL[5],MinItems[6],Metrics[7],MetricFilterIDs[8],Stored[9],Blocker[10],Weight[11],ThresholdIDs[12]
|
||||
cgrates.org,STATS_1,FLTR_ACNT_1001_1002,2014-07-29T15:00:00Z,100,-1,,,,,true,,*none
|
||||
cgrates.org,STATS_1,,,,,,*tcc;*asr,,,,,
|
||||
cgrates.org,STATS_1,,,,,,*sum:~*req.Usage,,,,,
|
||||
|
8
data/tariffplans/tutorial2/Suppliers.csv
Normal file
8
data/tariffplans/tutorial2/Suppliers.csv
Normal file
@@ -0,0 +1,8 @@
|
||||
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParamameters,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,SupplierBlocker,SupplierParameters,Weight
|
||||
cgrates.org,SPL_ACNT_1001,*string:~*req.Account:1001,2017-11-27T00:00:00Z,*weight,,,,,,,,,,,10
|
||||
cgrates.org,SPL_ACNT_1001,,,,,supplier1,,,,,,10,,,
|
||||
cgrates.org,SPL_ACNT_1001,,,,,supplier2,,,,,,20,,,
|
||||
cgrates.org,SPL_ACNT_1002,*string:~*req.Account:1002,2017-11-27T00:00:00Z,*lc,,,,,,,,,,,10
|
||||
cgrates.org,SPL_ACNT_1002,,,,,supplier1,,,RP_SPL1,,,,,,
|
||||
cgrates.org,SPL_ACNT_1002,,,,,supplier2,,,RP_SPL2,,,,,,
|
||||
|
||||
|
2
data/tariffplans/tutorial2/Thresholds.csv
Normal file
2
data/tariffplans/tutorial2/Thresholds.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],MaxHits[4],MinHits[5],MinSleep[6],Blocker[7],Weight[8],ActionIDs[9],Async[10]
|
||||
cgrates.org,THD_ACNT_1001,*string:~*req.Account:1001;*gte:~*req.Usage:2m,2014-07-29T15:00:00Z,1,1,1s,false,10,ACT_LOG_WARNING,true
|
||||
|
@@ -187,6 +187,7 @@ route[CGR_CALL_END] {
|
||||
\"AnswerTime\":\"$dlg(start_ts)\",
|
||||
\"PaypalAccount\":\"$dlg_var(paypalAccount)\",
|
||||
\"SetupTime\":\"$dlg_var(SetupTime)\",
|
||||
\"Usage\":\"$var(callDur)\"}");
|
||||
\"Usage\":\"$var(callDur)\",
|
||||
\"Supplier\":\"$dlg_var(cgrSupplier)\"}");
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
debug=2
|
||||
log_stderror=no
|
||||
|
||||
listen=udp:enp0s3:5060
|
||||
listen=udp:127.0.0.1:5080
|
||||
listen=udp:127.0.0.1:5060
|
||||
listen=udp:enp0s3:5080
|
||||
|
||||
memdbg=5
|
||||
memlog=5
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# re-generating the scenario with different options.#
|
||||
#
|
||||
# Please refer to the Core CookBook at:
|
||||
# https://opensips.org/Resources/DocsCookbooks
|
||||
# http://www.opensips.org/Resources/DocsCookbooks
|
||||
# for a explanation of possible statements, functions and parameters.
|
||||
#
|
||||
|
||||
@@ -23,11 +23,7 @@ udp_workers=4
|
||||
|
||||
auto_aliases=no
|
||||
|
||||
listen=udp:enp0s3:5060
|
||||
listen=udp:127.0.0.1:5080
|
||||
listen=udp:127.0.0.1:5060
|
||||
listen=udp:enp0s3:5080
|
||||
|
||||
socket=udp:enp0s8:5060
|
||||
|
||||
|
||||
####### Modules Section ########
|
||||
@@ -85,7 +81,15 @@ loadmodule "proto_udp.so"
|
||||
#### CGRateS module
|
||||
loadmodule "dialog.so"
|
||||
loadmodule "cgrates.so"
|
||||
modparam("cgrates", "cgrates_engine", "127.0.0.1:2014")
|
||||
modparam("cgrates", "cgrates_engine", "192.168.56.111:2014")
|
||||
|
||||
#### MySQL module
|
||||
loadmodule "db_mysql.so"
|
||||
|
||||
#### Drouting module
|
||||
loadmodule "drouting.so"
|
||||
modparam("drouting", "db_url",
|
||||
"mysql://opensips:opensipsrw@localhost/opensips")
|
||||
|
||||
|
||||
####### Routing Logic ########
|
||||
@@ -201,7 +205,7 @@ route{
|
||||
# check auth with CGRateS
|
||||
$cgr_opt(GetMaxUsage) = 1; # also retrieve the max usage
|
||||
$cgr_opt(GetAttributes) = 1;
|
||||
$cgr_opt(GetSuppliers) = 1;
|
||||
$cgr_opt(GetRoutes) = 1;
|
||||
$cgr_opt(AuthorizeResources) = 1;
|
||||
$cgr_opt(AllocateResources) = 1;
|
||||
$cgr_opt(ReleaseResources) = 1;
|
||||
@@ -218,29 +222,96 @@ route{
|
||||
}
|
||||
|
||||
route [resume_cgr_auth] {
|
||||
if ($rc != 1) {
|
||||
xlog("Call not authorized: code=$cgrret!\n");
|
||||
$var(rc) = $rc;
|
||||
# with GetMaxUsage == false, cgrates_auth() returns -2 on success
|
||||
if ($var(rc) < 0 && ($cgr_ret(MaxUsage) != 0 || $var(rc) != -2)) {
|
||||
xlog("L_NOTICE", "[$ci] CGRateS auth failed: rc=$var(rc), code=$cgr_ret\n");
|
||||
send_reply(403, "Forbidden");
|
||||
exit;
|
||||
}
|
||||
|
||||
# Set the returned attributes from CGRateS as script pseudovariables
|
||||
$var(idx) = 0;
|
||||
while ($(cgr_ret(AttributesDigest){s.select,$var(idx),,}) != NULL) {
|
||||
$avp($(cgr_ret(AttributesDigest){s.select,$var(idx),,}{s.select,0,:}))
|
||||
= $(cgr_ret(AttributesDigest){s.select,$var(idx),,}{s.select,1,:});
|
||||
$var(idx) = $var(idx) + 1;
|
||||
}
|
||||
cgrates_acc("cdr|missed", "$fU", "$rU");
|
||||
xlog("### Have authorized the call and it should go through");
|
||||
route(relay);
|
||||
|
||||
# Enable CDRs being sent to CGRateS
|
||||
cgrates_acc("cdr|missed", "$fU", "$rU");
|
||||
|
||||
if ( $cgr_ret(RoutesDigest)==NULL ) { # no routing requested
|
||||
route(relay);
|
||||
}
|
||||
|
||||
xlog("L_INFO", "[$ci] CGRateS auth OK, with routes: <$cgr_ret(RoutesDigest)>\n");
|
||||
$avp(carriers) := $cgr_ret(RoutesDigest);
|
||||
$avp(carriers_idx) := 0;
|
||||
|
||||
route( to_carriers );
|
||||
}
|
||||
|
||||
|
||||
route[to_carriers] {
|
||||
|
||||
xlog("L_INFO", "[$ci] routing to carrier IDX $avp(carriers_idx)\n");
|
||||
|
||||
$var(carrier) = $(avp(carriers){s.select,$avp(carriers_idx),,});
|
||||
if ( $var(carrier) == NULL) {
|
||||
send_reply( 404 , "No route available to route");
|
||||
exit;
|
||||
}
|
||||
$cgr(RouteID) = $var(carrier);
|
||||
|
||||
xlog("L_INFO", "[$ci] routing to carrier <$var(carrier)>\n");
|
||||
$avp(carriers_idx) := $avp(carriers_idx) + 1;
|
||||
|
||||
#if ( !route_to_carrier("$var(carrier)") ) {
|
||||
# xlog("L_INFO", "[$ci] failed to route to carrier, skipping>\n");
|
||||
# route( to_carriers );
|
||||
# exit;
|
||||
#}
|
||||
|
||||
t_on_failure("gw_failure");
|
||||
t_relay();
|
||||
|
||||
#end;
|
||||
|
||||
}
|
||||
|
||||
failure_route[gw_failure] {
|
||||
xlog("L_INFO", "[$ci] GW call failed to established with $T_reply_code code\n");
|
||||
|
||||
if (t_was_cancelled()) {
|
||||
exit;
|
||||
}
|
||||
|
||||
# failure indication about GWs?
|
||||
if ( t_check_status("(408)|([56][0-9][0-9])") ) {
|
||||
xlog("L_INFO", "[$ci] GW $rd failed with $T_reply_code -> retry\n");
|
||||
if ( use_next_gw() ) {
|
||||
xlog("L_INFO", "[$ci] using new GW <$rd>\n");
|
||||
t_on_failure("gw_failure");
|
||||
t_relay();
|
||||
#end
|
||||
}
|
||||
|
||||
# no more GWs for the carrier, try the next carrier
|
||||
route( to_carriers );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
route[relay] {
|
||||
# for INVITEs enable some additional helper routes
|
||||
if (is_method("INVITE")) {
|
||||
t_on_branch("per_branch_ops");
|
||||
t_on_reply("handle_nat");
|
||||
t_on_failure("missed_call");
|
||||
t_on_reply("handle_reply");
|
||||
t_on_failure("handle_failure");
|
||||
}
|
||||
|
||||
if (!t_relay()) {
|
||||
@@ -257,13 +328,13 @@ branch_route[per_branch_ops] {
|
||||
}
|
||||
|
||||
|
||||
onreply_route[handle_nat] {
|
||||
onreply_route[handle_reply] {
|
||||
xlog("incoming reply\n");
|
||||
}
|
||||
|
||||
|
||||
failure_route[missed_call] {
|
||||
failure_route[handle_failure] {
|
||||
if (t_was_cancelled()) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@ Kamailio_ Integration Tutorials
|
||||
===============================
|
||||
|
||||
In these tutorials we exemplify a few cases of integration between Kamailio_ and CGRateS_. We start with common steps, installation and postinstall processes, then we dive into particular configurations, depending on the case we run.
|
||||
Together with the server side installation we describe here, one should consider installing the preferred SIP UA which is not part of this tutorial.
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
tut_kamailio_installs
|
||||
tut_jitsi_installs
|
||||
tut_kamailio_evapi
|
||||
tut_cgrates_usage
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Scenario
|
||||
|
||||
- Kamailio default configuration modified for **CGRateS** interaction. For script maintainability and simplicity we have separated CGRateS specific routes in *kamailio-cgrates.cfg* file which is included in main *kamailio.cfg* via include directive.
|
||||
|
||||
- Considering the following users (with configs hardcoded in the *kamailio.cfg* configuration script and loaded in htable): 1001-prepaid, 1002-postpaid, 1003-pseudoprepaid, 1004-rated, 1005-rated, 1006-prepaid, 1007-prepaid.
|
||||
- Considering the following users: 1001-prepaid, 1002-postpaid, 1003-pseudoprepaid, stored within CGRateS AttributeS directly.
|
||||
|
||||
- **CGRateS** with following components:
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Software installation
|
||||
=====================
|
||||
|
||||
We have chosen Debian Jessie as operating system, since all the software components we use provide packaging for it.
|
||||
We have chosen Debian Bullseye as operating system, since all the software components we use provide packaging for it.
|
||||
|
||||
CGRateS
|
||||
--------
|
||||
@@ -13,14 +13,15 @@ CGRateS
|
||||
Kamailio_
|
||||
---------
|
||||
|
||||
We got Kamailio_ installed via following commands:
|
||||
We got Kamailio_ installed via following commands, documented in KamailioDebianInstallation_ section:
|
||||
::
|
||||
|
||||
wget -O- http://deb.kamailio.org/kamailiodebkey.gpg | sudo apt-key add -
|
||||
echo "deb http://deb.kamailio.org/kamailio56 stretch main" > /etc/apt/sources.list.d/kamailio.list
|
||||
wget -O- https://deb.kamailio.org/kamailiodebkey.gpg | sudo apt-key add -
|
||||
echo "deb http://deb.kamailio.org/kamailio56 bullseye main" > /etc/apt/sources.list.d/kamailio.list
|
||||
apt-get update
|
||||
apt-get install kamailio kamailio-extra-modules kamailio-json-modules
|
||||
|
||||
Once installed we proceed with loading the configuration out of specific tutorial cases bellow.
|
||||
|
||||
.. _Kamailio: https://www.kamailio.org/w/
|
||||
.. _KamailioDebianInstallation: https://www.kamailio.org/wiki/packages/debs
|
||||
|
||||
@@ -8,8 +8,7 @@ In these tutorials we exemplify a few cases of integration between OpenSIPS_ and
|
||||
:maxdepth: 2
|
||||
|
||||
tut_opensips_installs
|
||||
tut_jitsi_installs
|
||||
tut_opensips_event
|
||||
tut_osips_native
|
||||
tut_cgrates_usage
|
||||
|
||||
.. _OpenSIPS: https://opensips.org/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Software installation
|
||||
=====================
|
||||
|
||||
We have chosen Debian Jessie as operating system, since all the software components we use provide packaging for it.
|
||||
We have chosen Debian Buster as operating system, since all the software components we use provide packaging for it.
|
||||
|
||||
CGRateS
|
||||
--------
|
||||
@@ -16,9 +16,10 @@ We got OpenSIPS_ installed via following commands:
|
||||
::
|
||||
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 049AD65B
|
||||
echo "deb http://apt.opensips.org jessie 2.4-nightly" >/etc/apt/sources.list.d/opensips.list
|
||||
echo "deb https://apt.opensips.org buster 3.3-releases" >/etc/apt/sources.list.d/opensips.list
|
||||
echo "deb https://apt.opensips.org buster cli-nightly" >/etc/apt/sources.list.d/opensips-cli.list
|
||||
apt-get update
|
||||
apt-get install opensips opensips-cgrates-module
|
||||
sudo apt-get install opensips opensips-mysql-module opensips-cgrates-module opensips-cli
|
||||
|
||||
Once installed we proceed with loading the configuration out of specific tutorial cases bellow.
|
||||
|
||||
|
||||
@@ -1,24 +1,36 @@
|
||||
OpenSIPS_ interaction via *event_datagram*
|
||||
===========================================
|
||||
OpenSIPS_ interaction via own *cgrates* module
|
||||
===============================================
|
||||
|
||||
Scenario
|
||||
--------
|
||||
|
||||
- OpenSIPS out of *residential* configuration generated.
|
||||
|
||||
- Considering the following users (with configs hardcoded in the *opensips.cfg* configuration script): 1002-postpaid, 1003-pseudoprepaid, 1004-rated, 1007-rated.
|
||||
- The users are all defined within CGRateS.
|
||||
- For simplicity we configure no authentication (WARNING: Not for production usage).
|
||||
|
||||
- **CGRateS** with following components:
|
||||
- **CGRateS** with following subsystems:
|
||||
|
||||
- CGR-SM started as translator between OpenSIPS_ and **cgr-rater** for both authorization events (pseudoprepaid) as well as CDR ones.
|
||||
- CGR-CDRS component processing raw CDRs from CGR-SM component and storing them inside CGR StorDB.
|
||||
- CGR-CDRE exporting rated 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*).
|
||||
- **SM**: (SessionManager) started as gateway between OpenSIPS_ and rest of CGRateS subsystems.
|
||||
- **ChargerS**: used to decide the number of billing runs for customer/supplier charging.
|
||||
- **AttributeS**: used to populate extra data to requests (ie: prepaid/postpaid, passwords, paypal account, LCR profile).
|
||||
- **RALs**: used to calculate costs as well as account bundle management.
|
||||
- **SupplierS**: selection of suppliers for each session. This will work in tandem with OpenSIPS_'s DRouting module.
|
||||
- **StatS**: computing statistics in real-time regarding sessions and their charging.
|
||||
- **ThresholdS**: monitoring and reacting to events coming from above subsystems.
|
||||
- **CDRe**: exporting rated CDRs from CGR StorDB (export path: */tmp*).
|
||||
|
||||
|
||||
Creating OpenSIPS_ database for DRouting module
|
||||
-----------------------------------------------
|
||||
|
||||
::
|
||||
|
||||
opensips-cli -x database create
|
||||
|
||||
|
||||
Starting OpenSIPS_ with custom configuration
|
||||
----------------------------------------------
|
||||
--------------------------------------------
|
||||
|
||||
::
|
||||
|
||||
Reference in New Issue
Block a user