mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
SM-FreeSWITCH: process all CDRs instead of just prepaid/pseudoprepaid, adding cdrstats to tariffplans/tutorial folder
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
#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
|
||||
STANDARD_TRIGGERS,*monetary,*out,*max_balance,20,false,0,,,,,,,LOG_WARNING,10
|
||||
STANDARD_TRIGGERS,*monetary,*out,*max_balance,100,false,0,,,,,,,DISABLE_AND_LOG,10
|
||||
CDRST1_WARN,,,*min_asr,45,true,1m,,,,,,3,LOG_WARNING,10
|
||||
CDRST1_WARN,,,*min_acd,10,true,1m,,,,,,5,LOG_WARNING,10
|
||||
CDRST1_WARN,,,*max_acc,10,true,1m,,,,,,5,LOG_WARNING,10
|
||||
CDRST1001_WARN,,,*min_asr,65,true,1m,,,,,,3,LOG_WARNING,10
|
||||
CDRST1001_WARN,,,*min_acd,10,true,1m,,,,,,5,LOG_WARNING,10
|
||||
CDRST1001_WARN,,,*max_acc,5,true,1m,,,,,,5,LOG_WARNING,10
|
||||
CDRST3_WARN,,,*min_acd,60,true,1m,,,,,,5,LOG_WARNING,10
|
||||
CDRST3_WARN,,,*min_acd,60,true,1m,,,,,,5,LOG_WARNING,10
|
||||
|
||||
|
@@ -5,3 +5,5 @@ 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
|
||||
DISABLE_AND_LOG,*log,,,,,,,,,,10
|
||||
DISABLE_AND_LOG,*disable_account,,,,,,,,,,10
|
||||
|
||||
|
@@ -1,13 +1,12 @@
|
||||
#Id,QueueLength,TimeWindow,Metric,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers
|
||||
CDRST1,10,0,ASR,,,,,,,cgrates.org,,,,,,default,,,,CDRST1_WARN
|
||||
CDRST1,,,ACD,,,,,,,,,,,,,,,,,
|
||||
CDRST1,,,ACC,,,,,,,,,,,,,,,,,
|
||||
CDRST_1001,10,10m,ASR,,,,,,,cgrates.org,,,1001,,,default,,,,CDRST1001_WARN
|
||||
CDRST_1001,,,ACD,,,,,,,,,,,,,,,,,
|
||||
CDRST_1001,,,ACC,,,,,,,,,,,,,,,,,
|
||||
CDRST_1002,10,10m,ASR,,,,,,,cgrates.org,,,1002,,,default,,,,CDRST1001_WARN
|
||||
CDRST_1002,,,ACD,,,,,,,,,,,,,,,,,
|
||||
CDRST_1002,,,ACC,,,,,,,,,,,,,,,,,
|
||||
CDRST_1003,,,ASR,,,,,,,cgrates.org,,,,1003,,default,,,,CDRST3_WARN
|
||||
CDRST_1003,,,ACD,,,,,,,,,,,,,,,,,
|
||||
|
||||
#Id,QueueLength,TimeWindow,Metric,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers
|
||||
CDRST1,10,0,ASR,,,,,,,cgrates.org,,,,,,default,,,,CDRST1_WARN
|
||||
CDRST1,,,ACD,,,,,,,,,,,,,,,,,
|
||||
CDRST1,,,ACC,,,,,,,,,,,,,,,,,
|
||||
CDRST_1001,10,10m,ASR,,,,,,,cgrates.org,,,1001,,,default,,,,CDRST1001_WARN
|
||||
CDRST_1001,,,ACD,,,,,,,,,,,,,,,,,
|
||||
CDRST_1001,,,ACC,,,,,,,,,,,,,,,,,
|
||||
CDRST_1002,10,10m,ASR,,,,,,,cgrates.org,,,1002,,,default,,,,CDRST1001_WARN
|
||||
CDRST_1002,,,ACD,,,,,,,,,,,,,,,,,
|
||||
CDRST_1002,,,ACC,,,,,,,,,,,,,,,,,
|
||||
CDRST_1003,,,ASR,,,,,,,cgrates.org,,,,1003,,default,,,,CDRST3_WARN
|
||||
CDRST_1003,,,ACD,,,,,,,,,,,,,,,,,
|
||||
|
||||
|
@@ -120,55 +120,55 @@ enabled = true # Start the CDR Server service: <true|false>.
|
||||
enabled = true # Starts SessionManager service: <true|false>
|
||||
# switch_type = freeswitch # Defines the type of switch behind: <freeswitch>
|
||||
# rater = internal # Address where to reach the Rater <""|internal|127.0.0.1:2013>
|
||||
# cdrs = # Address where to reach CDR Server, empty to disable CDR capturing <""|internal|127.0.0.1:2013>
|
||||
cdrs = internal # Address where to reach CDR Server, empty to disable CDR capturing <""|internal|127.0.0.1:2013>
|
||||
# reconnects = 3 # Number of reconnects to rater/cdrs before giving up.
|
||||
# debit_interval = 10 # Interval to perform debits on.
|
||||
debit_interval = 2 # Interval to perform debits on.
|
||||
# min_call_duration = 0s # Only authorize calls with allowed duration bigger than this
|
||||
# max_call_duration = 3h # Maximum call duration a prepaid call can last
|
||||
|
||||
[freeswitch]
|
||||
# server = 127.0.0.1:8021 # Adress where to connect to FreeSWITCH socket.
|
||||
# passwd = ClueCon # FreeSWITCH socket password.
|
||||
# reconnects = 5 # Number of attempts on connect failure.
|
||||
# min_dur_low_balance = 5s # Threshold which will trigger low balance warnings for prepaid calls (needs to be lower than debit_interval)
|
||||
# low_balance_ann_file = # File to be played when low balance is reached for prepaid calls
|
||||
# empty_balance_context = # If defined, prepaid calls will be transfered to this context on empty balance
|
||||
# empty_balance_ann_file = # File to be played before disconnecting prepaid calls on empty balance (applies only if no context defined)
|
||||
# passwd = ClueCon # FreeSWITCH socket password.
|
||||
# reconnects = 5 # Number of attempts on connect failure.
|
||||
# min_dur_low_balance = 5s # Threshold which will trigger low balance warnings for prepaid calls (needs to be lower than debit_interval)
|
||||
# low_balance_ann_file = # File to be played when low balance is reached for prepaid calls
|
||||
# empty_balance_context = # If defined, prepaid calls will be transfered to this context on empty balance
|
||||
# empty_balance_ann_file = # File to be played before disconnecting prepaid calls on empty balance (applies only if no context defined)
|
||||
# cdr_extra_fields = # Extra fields to store in CDRs in case of processing them
|
||||
|
||||
[opensips]
|
||||
# listen_udp = 127.0.0.1:2020 # Address where to listen for datagram events coming from OpenSIPS
|
||||
# mi_addr = 127.0.0.1:8020 # Adress where to reach OpenSIPS mi_datagram module
|
||||
# mi_addr = 127.0.0.1:8020 # Adress where to reach OpenSIPS mi_datagram module
|
||||
# events_subscribe_interval = 60s # Automatic events subscription to OpenSIPS, 0 to disable it
|
||||
# reconnects = 3 # Number of attempts on connect failure.
|
||||
# reconnects = 3 # Number of attempts on connect failure.
|
||||
|
||||
[derived_charging]
|
||||
# run_ids = # Identifiers of additional sessions control.
|
||||
# run_filters = # List of cdr field filters for each run.
|
||||
# reqtype_fields = # Name of request type fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# run_ids = # Identifiers of additional sessions control.
|
||||
# run_filters = # List of cdr field filters for each run.
|
||||
# reqtype_fields = # Name of request type fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# direction_fields = # Name of direction fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# tenant_fields = # Name of tenant fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# tenant_fields = # Name of tenant fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# category_fields = # Name of tor fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# account_fields = # Name of account fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# subject_fields = # Name of fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# account_fields = # Name of account fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# subject_fields = # Name of fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# destination_fields = # Name of destination fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# setup_time_fields = # Name of setup_time fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# answer_time_fields = # Name of answer_time fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# usage_fields = # Name of usage fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# usage_fields = # Name of usage fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# combined_chargers = true # Combine accounts specific derived_chargers with server configured ones <true|false>.
|
||||
|
||||
[history_server]
|
||||
enabled = true # Starts History service: <true|false>.
|
||||
enabled = true # Starts History service: <true|false>.
|
||||
# history_dir = /tmp/cgrates/history # Location on disk where to store history files.
|
||||
# save_interval = 1s # Interval to save changed cache into .git archive
|
||||
# save_interval = 1s # Interval to save changed cache into .git archive
|
||||
|
||||
[history_agent]
|
||||
enabled = true # Starts History as a client: <true|false>.
|
||||
# server = internal # Address where to reach the master history server: <internal|x.y.z.y:1234>
|
||||
# server = internal # Address where to reach the master history server: <internal|x.y.z.y:1234>
|
||||
|
||||
[mailer]
|
||||
# server = localhost # The server to use when sending emails out
|
||||
# auth_user = cgrates # Authenticate to email server using this user
|
||||
# auth_passwd = CGRateS.org # Authenticate to email server with this password
|
||||
# server = localhost # The server to use when sending emails out
|
||||
# auth_user = cgrates # Authenticate to email server using this user
|
||||
# auth_passwd = CGRateS.org # Authenticate to email server with this password
|
||||
# from_address = cgr-mailer@localhost.localdomain # From address used when sending emails out
|
||||
|
||||
|
||||
@@ -252,6 +252,7 @@ func (sm *FSSessionManager) OnChannelAnswer(ev Event) {
|
||||
}
|
||||
|
||||
func (sm *FSSessionManager) OnChannelHangupComplete(ev Event) {
|
||||
go sm.processCdr(ev.AsStoredCdr())
|
||||
s := sm.GetSession(ev.GetUUID())
|
||||
if s == nil { // Not handled by us
|
||||
return
|
||||
@@ -341,13 +342,16 @@ func (sm *FSSessionManager) OnChannelHangupComplete(ev Event) {
|
||||
lastCC.Cost -= cost
|
||||
lastCC.Timespans.Compress()
|
||||
}
|
||||
}
|
||||
|
||||
func (sm *FSSessionManager) processCdr(storedCdr *utils.StoredCdr) error {
|
||||
if sm.cdrs != nil {
|
||||
var reply string
|
||||
storedCdr := ev.AsStoredCdr()
|
||||
if err := sm.cdrs.ProcessCdr(storedCdr, &reply); err != nil {
|
||||
engine.Logger.Err(fmt.Sprintf("<SM-FreeSWITCH> Failed processing CDR, cgrid: %s, accid: %s, error: <%s>", storedCdr.CgrId, storedCdr.AccId, err.Error()))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sm *FSSessionManager) GetDebitPeriod() time.Duration {
|
||||
|
||||
Reference in New Issue
Block a user