FS Event parsing cgr_category instead of cgr_tor, zero FS configuration support for passive billing scenarios

This commit is contained in:
DanB
2014-08-05 16:03:02 +02:00
parent 33e3f3fd66
commit 71a932e343
9 changed files with 112 additions and 47 deletions

View File

@@ -108,6 +108,7 @@ type CGRConfig struct {
SMEnabled bool
SMSwitchType string
SMRater string // address where to access rater. Can be internal, direct rater address or the address of a balancer
SMCdrS string //
SMReconnects int // Number of reconnect attempts to rater
SMDebitInterval int // the period to be debited in advanced during a call (in seconds)
SMMaxCallDuration time.Duration // The maximum duration of a call
@@ -129,7 +130,6 @@ type CGRConfig struct {
OsipsListenUdp string // Address where to listen for event datagrams coming from OpenSIPS
OsipsMiAddr string // Adress where to reach OpenSIPS mi_datagram module
OsipsEvSubscInterval time.Duration // Refresh event subscription at this interval
OsipCDRS string // Address where to reach CDR Server, empty to disable CDR processing <""|internal|127.0.0.1:2013>
OsipsReconnects int // Number of attempts on connect failure.
HistoryAgentEnabled bool // Starts History as an agent: <true|false>.
HistoryServer string // Address where to reach the master history server: <internal|x.y.z.y:1234>
@@ -217,6 +217,7 @@ func (self *CGRConfig) setDefaults() error {
self.SMEnabled = false
self.SMSwitchType = FS
self.SMRater = utils.INTERNAL
self.SMCdrS = ""
self.SMReconnects = 3
self.SMDebitInterval = 10
self.SMMaxCallDuration = time.Duration(3) * time.Hour
@@ -231,7 +232,6 @@ func (self *CGRConfig) setDefaults() error {
self.OsipsListenUdp = "127.0.0.1:2020"
self.OsipsMiAddr = "127.0.0.1:8020"
self.OsipsEvSubscInterval = time.Duration(60) * time.Second
self.OsipCDRS = "internal"
self.OsipsReconnects = 3
self.HistoryAgentEnabled = false
self.HistoryServerEnabled = false
@@ -554,6 +554,9 @@ func loadConfig(c *conf.ConfigFile) (*CGRConfig, error) {
if hasOpt = c.HasOption("session_manager", "rater"); hasOpt {
cfg.SMRater, _ = c.GetString("session_manager", "rater")
}
if hasOpt = c.HasOption("session_manager", "cdrs"); hasOpt {
cfg.SMCdrS, _ = c.GetString("session_manager", "cdrs")
}
if hasOpt = c.HasOption("session_manager", "reconnects"); hasOpt {
cfg.SMReconnects, _ = c.GetInt("session_manager", "reconnects")
}
@@ -608,9 +611,6 @@ func loadConfig(c *conf.ConfigFile) (*CGRConfig, error) {
return nil, err
}
}
if hasOpt = c.HasOption("opensips", "cdrs"); hasOpt {
cfg.OsipCDRS, _ = c.GetString("opensips", "cdrs")
}
if hasOpt = c.HasOption("opensips", "reconnects"); hasOpt {
cfg.OsipsReconnects, _ = c.GetInt("opensips", "reconnects")
}

View File

@@ -117,6 +117,7 @@ func TestDefaults(t *testing.T) {
eCfg.SMEnabled = false
eCfg.SMSwitchType = FS
eCfg.SMRater = utils.INTERNAL
eCfg.SMCdrS = ""
eCfg.SMReconnects = 3
eCfg.SMDebitInterval = 10
eCfg.SMMinCallDuration = time.Duration(0)
@@ -131,7 +132,6 @@ func TestDefaults(t *testing.T) {
eCfg.OsipsListenUdp = "127.0.0.1:2020"
eCfg.OsipsMiAddr = "127.0.0.1:8020"
eCfg.OsipsEvSubscInterval = time.Duration(60) * time.Second
eCfg.OsipCDRS = "internal"
eCfg.OsipsReconnects = 3
eCfg.DerivedChargers = make(utils.DerivedChargers, 0)
eCfg.CombinedDerivedChargers = true
@@ -274,6 +274,7 @@ func TestConfigFromFile(t *testing.T) {
eCfg.SMEnabled = true
eCfg.SMSwitchType = "test"
eCfg.SMRater = "test"
eCfg.SMCdrS = "test"
eCfg.SMReconnects = 99
eCfg.SMDebitInterval = 99
eCfg.SMMinCallDuration = time.Duration(98) * time.Second
@@ -288,7 +289,6 @@ func TestConfigFromFile(t *testing.T) {
eCfg.OsipsListenUdp = "test"
eCfg.OsipsMiAddr = "test"
eCfg.OsipsEvSubscInterval = time.Duration(99) * time.Second
eCfg.OsipCDRS = "test"
eCfg.OsipsReconnects = 99
eCfg.DerivedChargers = utils.DerivedChargers{&utils.DerivedCharger{RunId: "test", RunFilters: "", ReqTypeField: "test", DirectionField: "test", TenantField: "test",
CategoryField: "test", AccountField: "test", SubjectField: "test", DestinationField: "test", SetupTimeField: "test", AnswerTimeField: "test", UsageField: "test"}}

View File

@@ -94,7 +94,7 @@ enabled = true # Start the CDR stats service: <true|false>.
queue_length = 99 # Number of items in the stats buffer
time_window = 99 # Will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow
metrics = test # Stat metric ids to build
setup_interval = # Filter on CDR SetupTime
setup_interval = # Filter on CDR SetupTime
tors = test # Filter on CDR TOR fields
cdr_hosts= test # Filter on CDR CdrHost fields
cdr_sources = test # Filter on CDR CdrSource fields
@@ -105,16 +105,17 @@ categories = test # Filter on CDR Category fields
accounts = test # Filter on CDR Account fields
subjects = test # Filter on CDR Subject fields
destination_prefixes = test # Filter on CDR Destination prefixes
usage_interval = 99 # Filter on CDR Usage
mediation_run_ids = test # Filter on CDR MediationRunId fields
usage_interval = 99 # Filter on CDR Usage
mediation_run_ids = test # Filter on CDR MediationRunId fields
rated_accounts = test # Filter on CDR RatedAccount fields
rated_subjects = test # Filter on CDR RatedSubject fields
cost_intervals = 99 # Filter on CDR Cost
cost_intervals = 99 # Filter on CDR Cost
[session_manager]
enabled = true # Starts SessionManager service: <true|false>.
switch_type = test # Defines the type of switch behind: <freeswitch>.
rater = test # Address where to reach the Rater.
cdrs = test # Address where to reach CDR Server, empty to disable CDR capturing <""|internal|127.0.0.1:2013>
reconnects = 99 # Number of reconnects to rater before giving up.
debit_interval = 99 # Interval to perform debits on.
min_call_duration = 98 # Only authorize calls with allowed duration bigger than this