From 455379ef97fb86d97cadb6a1e4cff5770f5eb821 Mon Sep 17 00:00:00 2001 From: DanB Date: Sat, 2 Aug 2014 22:24:39 +0200 Subject: [PATCH] cgr-loader information formated with tab for verbose mode, adding data/tariffplans/tutorial folder to use as common tutorial tariff plan data --- data/tariffplans/tutorial/AccountActions.csv | 6 +++ data/tariffplans/tutorial/ActionPlans.csv | 5 ++ data/tariffplans/tutorial/ActionTriggers.csv | 9 ++++ data/tariffplans/tutorial/Actions.csv | 7 +++ data/tariffplans/tutorial/CdrStats.csv | 6 +++ data/tariffplans/tutorial/DerivedChargers.csv | 2 + .../tariffplans/tutorial/DestinationRates.csv | 8 ++++ data/tariffplans/tutorial/Destinations.csv | 4 ++ data/tariffplans/tutorial/README.md | 39 +++++++++++++++ data/tariffplans/tutorial/Rates.csv | 8 ++++ data/tariffplans/tutorial/RatingPlans.csv | 18 +++++++ data/tariffplans/tutorial/RatingProfiles.csv | 4 ++ data/tariffplans/tutorial/SharedGroups.csv | 2 + data/tariffplans/tutorial/Timings.csv | 7 +++ engine/loader_csv.go | 48 +++++++++---------- 15 files changed, 149 insertions(+), 24 deletions(-) create mode 100644 data/tariffplans/tutorial/AccountActions.csv create mode 100644 data/tariffplans/tutorial/ActionPlans.csv create mode 100644 data/tariffplans/tutorial/ActionTriggers.csv create mode 100644 data/tariffplans/tutorial/Actions.csv create mode 100644 data/tariffplans/tutorial/CdrStats.csv create mode 100644 data/tariffplans/tutorial/DerivedChargers.csv create mode 100644 data/tariffplans/tutorial/DestinationRates.csv create mode 100644 data/tariffplans/tutorial/Destinations.csv create mode 100644 data/tariffplans/tutorial/README.md create mode 100644 data/tariffplans/tutorial/Rates.csv create mode 100644 data/tariffplans/tutorial/RatingPlans.csv create mode 100644 data/tariffplans/tutorial/RatingProfiles.csv create mode 100644 data/tariffplans/tutorial/SharedGroups.csv create mode 100644 data/tariffplans/tutorial/Timings.csv diff --git a/data/tariffplans/tutorial/AccountActions.csv b/data/tariffplans/tutorial/AccountActions.csv new file mode 100644 index 000000000..4a8ecc33e --- /dev/null +++ b/data/tariffplans/tutorial/AccountActions.csv @@ -0,0 +1,6 @@ +#Tenant,Account,Direction,ActionPlanTag,ActionTriggersTag +cgrates.org,1001,*out,PACKAGE_10_SHARED_A_5,STANDARD_TRIGGERS +cgrates.org,1002;1006,*out,PACKAGE_10,STANDARD_TRIGGERS +cgrates.org,1003,*out,PACKAGE_10,STANDARD_TRIGGERS +cgrates.org,1004,*out,PACKAGE_10,STANDARD_TRIGGERS +cgrates.org,1007,*out,USE_SHARED_A,STANDARD_TRIGGERS diff --git a/data/tariffplans/tutorial/ActionPlans.csv b/data/tariffplans/tutorial/ActionPlans.csv new file mode 100644 index 000000000..ca6e464e2 --- /dev/null +++ b/data/tariffplans/tutorial/ActionPlans.csv @@ -0,0 +1,5 @@ +#Tag,ActionsTag,TimingTag,Weight +PACKAGE_10,TOPUP_RST_10,ASAP,10 +PACKAGE_10_SHARED_A_5,TOPUP_RST_5,ASAP,10 +PACKAGE_10_SHARED_A_5,TOPUP_RST_SHARED_5,ASAP,10 +USE_SHARED_A,SHARED_A_0,ASAP,10 diff --git a/data/tariffplans/tutorial/ActionTriggers.csv b/data/tariffplans/tutorial/ActionTriggers.csv new file mode 100644 index 000000000..e227892e0 --- /dev/null +++ b/data/tariffplans/tutorial/ActionTriggers.csv @@ -0,0 +1,9 @@ +#Tag,BalanceTag,Direction,ThresholdType,ThresholdValue,Recurrent,MinSleep,BalanceDestinationTag,BalanceWeight,BalanceExpiryTime,BalanceRatingSubject,BalanceSharedGroup,StatsMinQueuedItems,ActionsTag,Weight +STANDARD_TRIGGERS,*monetary,*out,*min_balance,2,false,0,,,,,,,LOG_WARNING,10 +STANDARD_TRIGGERS,*monetary,*out,*max_balance,20,false,0,,,,,,,LOG_WARNING,10 +STANDARD_TRIGGERS,*monetary,*out,*max_counter,5,false,0,FS_USERS,,,,,,LOG_WARNING,10 +CDRST5_WARN,,,*min_asr,45,true,1m,,,,,,3,LOG_WARNING,10 +CDRST5_WARN,,,*min_acd,10,true,1m,,,,,,5,LOG_WARNING,10 +CDRST5_WARN,,,*max_acc,10,true,1m,,,,,,5,LOG_WARNING,10 +CDRST6_WARN,,,*min_asr,30,true,0,,,,,,5,LOG_WARNING,10 +CDRST6_WARN,,,*min_acd,3,true,0,,,,,,2,LOG_WARNING,10 \ No newline at end of file diff --git a/data/tariffplans/tutorial/Actions.csv b/data/tariffplans/tutorial/Actions.csv new file mode 100644 index 000000000..e2153d6af --- /dev/null +++ b/data/tariffplans/tutorial/Actions.csv @@ -0,0 +1,7 @@ +#ActionsTag,Action,BalanceType,Direction,Units,ExpiryTime,DestinationTag,RatingSubject,BalanceWeight,SharedGroup,ExtraParameters,Weight +TOPUP_RST_10,*topup_reset,*monetary,*out,10,*unlimited,*any,,10,,,10 +TOPUP_RST_5,*topup_reset,*monetary,*out,5,*unlimited,*any,,20,,,10 +TOPUP_RST_5,*topup_reset,*voice,*out,5,*unlimited,DST_1002,SPECIAL_1002,20,,,10 +TOPUP_RST_SHARED_5,*topup,*monetary,*out,5,*unlimited,*any,,10,SHARED_A,,10 +SHARED_A_0,*topup_reset,*monetary,*out,0,*unlimited,*any,,10,SHARED_A,,10 +LOG_WARNING,*log,,,,,,,,,,10 diff --git a/data/tariffplans/tutorial/CdrStats.csv b/data/tariffplans/tutorial/CdrStats.csv new file mode 100644 index 000000000..f38beadcc --- /dev/null +++ b/data/tariffplans/tutorial/CdrStats.csv @@ -0,0 +1,6 @@ +#Id,QueueLength,TimeWindow,Metrics,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers +CDRST5,5,1m,ASR,,*voice,,,,*out,cgrates.org,call,1001,1001,,,default,,,,CDRST5_WARN +CDRST5,,,ACD,,,,,,,,,,,,,,,,, +CDRST5,,,ACC,,,,,,,,,,,,,,,,, +CDRST6,10,0,ASR,,,,,,,cgrates.org,,,,,,default,,,,CDRST6_WARN +CDRST6,,,ACD,,,,,,,,,,,,,,,,, \ No newline at end of file diff --git a/data/tariffplans/tutorial/DerivedChargers.csv b/data/tariffplans/tutorial/DerivedChargers.csv new file mode 100644 index 000000000..aed05a80d --- /dev/null +++ b/data/tariffplans/tutorial/DerivedChargers.csv @@ -0,0 +1,2 @@ +#Direction,Tenant,Category,Account,Subject,RunId,RunFilter,ReqTypeField,DirectionField,TenantField,TorField,AccountField,SubjectField,DestinationField,SetupTimeField,AnswerTimeField,UsageField +*out,cgrates.org,call,1001,1001,fs_json_run,,^rated,*default,*default,*default,*default,^1002,*default,*default,*default,*default diff --git a/data/tariffplans/tutorial/DestinationRates.csv b/data/tariffplans/tutorial/DestinationRates.csv new file mode 100644 index 000000000..b902c0601 --- /dev/null +++ b/data/tariffplans/tutorial/DestinationRates.csv @@ -0,0 +1,8 @@ +#Tag,DestinationsTag,RatesTag,RoundingMethod,RoundingDecimals +DR_1002_20CNT,DST_1002,RT_20CNT,*up,4 +DR_1002_10CNT,DST_1002,RT_10CNT,*up,4 +DR_1003_20CNT,DST_1003,RT_40CNT,*up,4 +DR_1003_10CNT,DST_1003,RT_10CNT,*up,4 +DR_FS_40CNT,DST_FS,RT_40CNT,*up,4 +DR_FS_10CNT,DST_FS,RT_10CNT,*up,4 +DR_SPECIAL_1002,DST_1002,RT_1CNT,*up,4 diff --git a/data/tariffplans/tutorial/Destinations.csv b/data/tariffplans/tutorial/Destinations.csv new file mode 100644 index 000000000..1c19d97ea --- /dev/null +++ b/data/tariffplans/tutorial/Destinations.csv @@ -0,0 +1,4 @@ +#Tag,Prefix +DST_1002,1002 +DST_1003,1003 +DST_FS,10 diff --git a/data/tariffplans/tutorial/README.md b/data/tariffplans/tutorial/README.md new file mode 100644 index 000000000..8209dcb4e --- /dev/null +++ b/data/tariffplans/tutorial/README.md @@ -0,0 +1,39 @@ +Tutorial FS_JSON +================ + +Scenario: +--------- + +- Create the necessary timings (always, asap, peak, offpeak). +- Configure 3 destinations (1002, 1003 and 10 used as catch all rule). +- As rating we configure the following: + + - Rate id: *RT_10CNT* with connect fee of 20cents, 10cents per minute for the first 60s in 60s increments followed by 5cents per minute in 1s increments. + - Rate id: *RT_20CNT* with connect fee of 40cents, 20cents per minute for the first 60s in 60s increments, followed by 10 cents per minute charged in 1s increments. + - Rate id: *RT_40CNT* with connect fee of 80cents, 40cents per minute for the first 60s in 60s increments, follwed by 20cents per minute charged in 10s increments. + - Will charge by default *RT_40CNT* for all FreeSWITCH_ destinations during peak time (Monday-Friday 08:00-19:00) and *RT_10CNT* during offpeatimes (rest). + - Account 1001 will receive a special *deal* for 1002 and 1003 destinations during peak times with *RT_20CNT*, otherwise same as default rating. + +- Create 5 accounts (equivalent of FreeSWITCH default test users - 1001, 1002, 1003, 1004, 1007). +- 1002, 1003, 1004 will receive 10units of *monetary balance. +- 1001 will receive 5 units of general *monetary and 5 units of shared balance in the shared group *SHARED_A*. +- 1007 will receive 0 units of shared balance in the shared group *SHARED_A*. +- Define the shared balance *SHARED_A* with debit policy *highest. + +- For each balance created, attach 3 triggers to control the balance: log on balance=2, log on balance=20, log on 5 mins talked towards 10xx destination. + +- Add 2 CDRStats Queue configurations: + + - CDRStatsQueueId: *CDRST5* with a QueueLength of 5 CDRs and a TimeWindow of 1 minute monitoring ASR, ACD and ACC for CDRs with filters on TOR=*voice, Direction=*out, Tenant=cgrates.org, Category=call, Account=1001, Subject=1001 and MediationRunId=default. To this queue we attach ActionTriggers profile named CDRST5_WARN + - CDRStatsQueueId: *CDRST6* with a QueueLength of 10 CDRs and no TimeWindow gathering ASR and ACD metrics with CDR filters on Tenant=cgrates.org and MediationRunId=default. To this queue we attach an ActionTrigger profile named CDRST6_WARN. +- ActionTrigger: *CDRST5_WARN* with thresholds explained bellow and having as action the *log on syslog + + - Threshold on *min_asr of 45, configured as recurrent with a sleep time of 1 minute and a minimum of 3 items in the stats queue. + - Threshold on *min_acd of 10, configured as recurrent with a sleep time of 1 minute and a minimum of 5 items in the stats queue. + - Threshold on *max_acc of 10, configured as recurrent with a sleep time of 1 minute and a minimum of 5 items in the stats queue. + +- ActionTrigger: *CDRST6_WARN* with thresholds explained bellow and having as action the *log on syslog + + - Threshold on *min_asr of 30, configured as recurrent without sleep time and a minimum of 5 items in the stats queue. + - Threshold on *min_acd of 3, configured as recurrent without sleep time and a minimum of 2 items in the stats queue. + diff --git a/data/tariffplans/tutorial/Rates.csv b/data/tariffplans/tutorial/Rates.csv new file mode 100644 index 000000000..5f571f24b --- /dev/null +++ b/data/tariffplans/tutorial/Rates.csv @@ -0,0 +1,8 @@ +#Tag,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart +RT_10CNT,0.2,0.1,60s,60s,0s +RT_10CNT,0,0.05,60s,1s,60s +RT_20CNT,0.4,0.2,60s,60s,0s +RT_20CNT,0,0.1,60s,1s,60s +RT_40CNT,0.8,0.4,60s,30s,0s +RT_40CNT,0,0.2,60s,10s,60s +RT_1CNT,0,0.01,60s,60s,0s diff --git a/data/tariffplans/tutorial/RatingPlans.csv b/data/tariffplans/tutorial/RatingPlans.csv new file mode 100644 index 000000000..7eb4dc71d --- /dev/null +++ b/data/tariffplans/tutorial/RatingPlans.csv @@ -0,0 +1,18 @@ +#Tag,DestinationRatesTag,TimingTag,Weight +RP_RETAIL1,DR_FS_40CNT,PEAK,10 +RP_RETAIL1,DR_FS_10CNT,OFFPEAK_MORNING,10 +RP_RETAIL1,DR_FS_10CNT,OFFPEAK_EVENING,10 +RP_RETAIL1,DR_FS_10CNT,OFFPEAK_WEEKEND,10 +RP_RETAIL2,DR_1002_20CNT,PEAK,10 +RP_RETAIL2,DR_1003_20CNT,PEAK,10 +RP_RETAIL2,DR_FS_40CNT,PEAK,10 +RP_RETAIL2,DR_1002_10CNT,OFFPEAK_MORNING,10 +RP_RETAIL2,DR_1002_10CNT,OFFPEAK_EVENING,10 +RP_RETAIL2,DR_1002_10CNT,OFFPEAK_WEEKEND,10 +RP_RETAIL2,DR_1003_10CNT,OFFPEAK_MORNING,10 +RP_RETAIL2,DR_1003_10CNT,OFFPEAK_EVENING,10 +RP_RETAIL2,DR_1003_10CNT,OFFPEAK_WEEKEND,10 +RP_RETAIL2,DR_FS_10CNT,OFFPEAK_MORNING,10 +RP_RETAIL2,DR_FS_10CNT,OFFPEAK_EVENING,10 +RP_RETAIL2,DR_FS_10CNT,OFFPEAK_WEEKEND,10 +RP_SPECIAL_1002,DR_SPECIAL_1002,ALWAYS,10 diff --git a/data/tariffplans/tutorial/RatingProfiles.csv b/data/tariffplans/tutorial/RatingProfiles.csv new file mode 100644 index 000000000..367d42cfd --- /dev/null +++ b/data/tariffplans/tutorial/RatingProfiles.csv @@ -0,0 +1,4 @@ +#Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject +*out,cgrates.org,call,*any,2014-01-14T00:00:00Z,RP_RETAIL1, +*out,cgrates.org,call,1001;1006,2014-01-14T00:00:00Z,RP_RETAIL2, +*out,cgrates.org,call,SPECIAL_1002,2014-01-14T00:00:00Z,RP_SPECIAL_1002, diff --git a/data/tariffplans/tutorial/SharedGroups.csv b/data/tariffplans/tutorial/SharedGroups.csv new file mode 100644 index 000000000..c01defac4 --- /dev/null +++ b/data/tariffplans/tutorial/SharedGroups.csv @@ -0,0 +1,2 @@ +#Id,Account,Strategy,RatingSubject +SHARED_A,*any,*highest, diff --git a/data/tariffplans/tutorial/Timings.csv b/data/tariffplans/tutorial/Timings.csv new file mode 100644 index 000000000..2c5ad517e --- /dev/null +++ b/data/tariffplans/tutorial/Timings.csv @@ -0,0 +1,7 @@ +#Tag,Years,Months,MonthDays,WeekDays,Time +ALWAYS,*any,*any,*any,*any,00:00:00 +ASAP,*any,*any,*any,*any,*asap +PEAK,*any,*any,*any,1;2;3;4;5,08:00:00 +OFFPEAK_MORNING,*any,*any,*any,1,00:00:00 +OFFPEAK_EVENING,*any,*any,*any,1;2;3;4;5,19:00:00 +OFFPEAK_WEEKEND,*any,*any,*any,6;7,00:00:00 diff --git a/engine/loader_csv.go b/engine/loader_csv.go index b0acdaf84..a05a05823 100644 --- a/engine/loader_csv.go +++ b/engine/loader_csv.go @@ -189,7 +189,7 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { dataStorage.(Storage).Flush() } if verbose { - log.Print("Destinations") + log.Print("Destinations:") } for _, d := range csvr.destinations { err = dataStorage.SetDestination(d) @@ -197,11 +197,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Print(d.Id, " : ", d.Prefixes) + log.Print("\t", d.Id, " : ", d.Prefixes) } } if verbose { - log.Print("Rating plans") + log.Print("Rating Plans:") } for _, rp := range csvr.ratingPlans { err = dataStorage.SetRatingPlan(rp) @@ -209,11 +209,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Print(rp.Id) + log.Print("\t", rp.Id) } } if verbose { - log.Print("Rating profiles") + log.Print("Rating Profiles:") } for _, rp := range csvr.ratingProfiles { err = dataStorage.SetRatingProfile(rp) @@ -221,11 +221,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Print(rp.Id) + log.Print("\t", rp.Id) } } if verbose { - log.Print("Action plans") + log.Print("Action Plans:") } for k, ats := range csvr.actionsTimings { err = accountingStorage.SetActionTimings(k, ats) @@ -233,11 +233,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Println(k) + log.Println("\t", k) } } if verbose { - log.Print("Shared groups") + log.Print("Shared Groups:") } for k, sg := range csvr.sharedGroups { err = accountingStorage.SetSharedGroup(sg) @@ -245,11 +245,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Println(k) + log.Println("\t", k) } } if verbose { - log.Print("LCR Rules") + log.Print("LCR Rules:") } for k, lcr := range csvr.lcrs { err = dataStorage.SetLCR(lcr) @@ -257,11 +257,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Println(k) + log.Println("\t", k) } } if verbose { - log.Print("Actions") + log.Print("Actions:") } for k, as := range csvr.actions { err = accountingStorage.SetActions(k, as) @@ -269,11 +269,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Println(k) + log.Println("\t", k) } } if verbose { - log.Print("Account actions") + log.Print("Account Actions:") } for _, ub := range csvr.accountActions { err = accountingStorage.SetAccount(ub) @@ -281,11 +281,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Println(ub.Id) + log.Println("\t", ub.Id) } } if verbose { - log.Print("Rating profile aliases") + log.Print("Rating Profile Aliases:") } if err := dataStorage.RemoveRpAliases(csvr.dirtyRpAliases); err != nil { return err @@ -296,11 +296,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Print(key) + log.Print("\t", key) } } if verbose { - log.Print("Account aliases") + log.Print("Account Aliases:") } if err := accountingStorage.RemoveAccAliases(csvr.dirtyAccAliases); err != nil { return err @@ -311,11 +311,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Print(key) + log.Print("\t", key) } } if verbose { - log.Print("Derived Chargers") + log.Print("Derived Chargers:") } for key, dcs := range csvr.derivedChargers { err = accountingStorage.SetDerivedChargers(key, dcs) @@ -323,11 +323,11 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Print(key) + log.Print("\t", key) } } if verbose { - log.Print("CDR Stats Queues") + log.Print("CDR Stats Queues:") } for _, sq := range csvr.cdrStats { err = dataStorage.SetCdrStats(sq) @@ -335,7 +335,7 @@ func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { return err } if verbose { - log.Print(sq.Id) + log.Print("\t", sq.Id) } } return