diff --git a/apier/v1/cdrs.go b/apier/v1/cdrs.go index b5e5ef6be..7879f64d5 100644 --- a/apier/v1/cdrs.go +++ b/apier/v1/cdrs.go @@ -54,14 +54,14 @@ func (self *ApierV1) ExportCsvCdrs(attr *AttrExpCsvCdrs, reply *ExportedCsvCdrs) if err != nil { return err } - fileName := path.Join(self.Config.CDRSExportPath, "cgr", "csv", fmt.Sprintf("cdrs_%d.csv", time.Now().Unix())) + fileName := path.Join(self.Config.CdreDir, "cgr", "csv", fmt.Sprintf("cdrs_%d.csv", time.Now().Unix())) fileOut, err := os.Create(fileName) if err != nil { return err } else { defer fileOut.Close() } - csvWriter := cdrexporter.NewCsvCdrWriter(fileOut, self.Config.RoundingDecimals, self.Config.CDRSExportExtraFields) + csvWriter := cdrexporter.NewCsvCdrWriter(fileOut, self.Config.RoundingDecimals, self.Config.CdreExtraFields) for _, cdr := range cdrs { if err := csvWriter.Write(cdr); err != nil { os.Remove(fileName) diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index b6820dcef..0490cd573 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -220,7 +220,7 @@ func startHistoryScribe() { var scribeServer history.Scribe if cfg.HistoryServerEnabled { - if scribeServer, err = history.NewFileScribe(cfg.HistoryPath, cfg.HistorySaveInterval); err != nil { + if scribeServer, err = history.NewFileScribe(cfg.HistoryDir, cfg.HistorySaveInterval); err != nil { engine.Logger.Crit(err.Error()) exitChan <- true return diff --git a/config/config.go b/config/config.go index f2497dd61..2619d0e95 100644 --- a/config/config.go +++ b/config/config.go @@ -89,8 +89,9 @@ type CGRConfig struct { CDRSListen string // CDRS's listening interface: . CDRSExtraFields []string //Extra fields to store in CDRs CDRSMediator string // Address where to reach the Mediator. Empty for disabling mediation. <""|internal> - CDRSExportPath string // Path towards exported cdrs - CDRSExportExtraFields []string // Extra fields list to add in exported CDRs + CdreCdrFormat string // Format of the exported CDRs. + CdreExtraFields []string // Extra fields list to add in exported CDRs + CdreDir string // Path towards exported cdrs directory CdrcEnabled bool // Enable CDR client functionality CdrcCdrs string // Address where to reach CDR server CdrcCdrsMethod string // Mechanism to use when posting CDRs on server @@ -136,7 +137,7 @@ type CGRConfig struct { HistoryServer string // Address where to reach the master history server: HistoryServerEnabled bool // Starts History as server: . HistoryListen string // History server listening interface: - HistoryPath string // Location on disk where to store history files. + HistoryDir string // Location on disk where to store history files. HistorySaveInterval time.Duration // The timout duration between history writes } @@ -177,8 +178,9 @@ func (self *CGRConfig) setDefaults() error { self.CDRSListen = "127.0.0.1:2022" self.CDRSExtraFields = []string{} self.CDRSMediator = "" - self.CDRSExportPath = "/var/log/cgrates/cdr/cdrexport/csv" - self.CDRSExportExtraFields = []string{} + self.CdreCdrFormat = "csv" + self.CdreExtraFields = []string{} + self.CdreDir = "/var/log/cgrates/cdr/cdrexport/csv" self.CdrcEnabled = false self.CdrcCdrs = "127.0.0.1:2022" self.CdrcCdrsMethod = "http_cgr" @@ -224,7 +226,7 @@ func (self *CGRConfig) setDefaults() error { self.HistoryServerEnabled = false self.HistoryServer = "127.0.0.1:2013" self.HistoryListen = "127.0.0.1:2013" - self.HistoryPath = "/var/log/cgrates/history" + self.HistoryDir = "/var/log/cgrates/history" self.HistorySaveInterval = time.Duration(1) * time.Second return nil } @@ -367,14 +369,17 @@ func loadConfig(c *conf.ConfigFile) (*CGRConfig, error) { if hasOpt = c.HasOption("cdrs", "mediator"); hasOpt { cfg.CDRSMediator, _ = c.GetString("cdrs", "mediator") } - if hasOpt = c.HasOption("cdrs", "export_path"); hasOpt { - cfg.CDRSExportPath, _ = c.GetString("cdrs", "export_path") + if hasOpt = c.HasOption("cdre", "cdr_format"); hasOpt { + cfg.CdreCdrFormat, _ = c.GetString("cdre", "cdr_format") } - if hasOpt = c.HasOption("cdrs", "export_extra_fields"); hasOpt { - if cfg.CDRSExportExtraFields, errParse = ConfigSlice(c, "cdrs", "export_extra_fields"); errParse != nil { + if hasOpt = c.HasOption("cdre", "extra_fields"); hasOpt { + if cfg.CdreExtraFields, errParse = ConfigSlice(c, "cdre", "extra_fields"); errParse != nil { return nil, errParse } } + if hasOpt = c.HasOption("cdre", "export_dir"); hasOpt { + cfg.CdreDir, _ = c.GetString("cdre", "export_dir") + } if hasOpt = c.HasOption("cdrc", "enabled"); hasOpt { cfg.CdrcEnabled, _ = c.GetBool("cdrc", "enabled") } @@ -535,8 +540,8 @@ func loadConfig(c *conf.ConfigFile) (*CGRConfig, error) { if hasOpt = c.HasOption("history_server", "listen"); hasOpt { cfg.HistoryListen, _ = c.GetString("history_server", "listen") } - if hasOpt = c.HasOption("history_server", "path"); hasOpt { - cfg.HistoryPath, _ = c.GetString("history_server", "path") + if hasOpt = c.HasOption("history_server", "history_dir"); hasOpt { + cfg.HistoryDir, _ = c.GetString("history_server", "history_dir") } if hasOpt = c.HasOption("history_server", "save_interval"); hasOpt { saveIntvlStr,_ := c.GetString("history_server", "save_interval") diff --git a/config/config_test.go b/config/config_test.go index a67c4fad7..6b1b69304 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -81,6 +81,10 @@ func TestDefaults(t *testing.T) { eCfg.CDRSEnabled = false eCfg.CDRSListen = "127.0.0.1:2022" eCfg.CDRSExtraFields = []string{} + eCfg.CDRSMediator = "" + eCfg.CdreCdrFormat = "csv" + eCfg.CdreExtraFields = []string{} + eCfg.CdreDir = "/var/log/cgrates/cdr/cdrexport/csv" eCfg.CdrcEnabled = false eCfg.CdrcCdrs = "127.0.0.1:2022" eCfg.CdrcCdrsMethod = "http_cgr" @@ -100,9 +104,6 @@ func TestDefaults(t *testing.T) { eCfg.CdrcAnswerTimeField = "8" eCfg.CdrcDurationField = "9" eCfg.CdrcExtraFields = []string{"10:supplier","11:orig_ip"} - eCfg.CDRSMediator = "" - eCfg.CDRSExportPath = "/var/log/cgrates/cdr/cdrexport/csv" - eCfg.CDRSExportExtraFields = []string{} eCfg.MediatorEnabled = false eCfg.MediatorListen = "127.0.0.1:2032" eCfg.MediatorRater = "127.0.0.1:2012" @@ -129,7 +130,7 @@ func TestDefaults(t *testing.T) { eCfg.HistoryServer = "127.0.0.1:2013" eCfg.HistoryServerEnabled = false eCfg.HistoryListen = "127.0.0.1:2013" - eCfg.HistoryPath = "/var/log/cgrates/history" + eCfg.HistoryDir = "/var/log/cgrates/history" eCfg.HistorySaveInterval = time.Duration(1)*time.Second if !reflect.DeepEqual(cfg, eCfg) { t.Log(eCfg) @@ -203,8 +204,9 @@ func TestConfigFromFile(t *testing.T) { eCfg.CDRSListen = "test" eCfg.CDRSExtraFields = []string{"test"} eCfg.CDRSMediator = "test" - eCfg.CDRSExportPath = "test" - eCfg.CDRSExportExtraFields = []string{"test"} + eCfg.CdreCdrFormat = "test" + eCfg.CdreExtraFields = []string{"test"} + eCfg.CdreDir = "test" eCfg.CdrcEnabled = true eCfg.CdrcCdrs = "test" eCfg.CdrcCdrsMethod = "test" @@ -250,7 +252,7 @@ func TestConfigFromFile(t *testing.T) { eCfg.HistoryServer = "test" eCfg.HistoryServerEnabled = true eCfg.HistoryListen = "test" - eCfg.HistoryPath = "test" + eCfg.HistoryDir = "test" eCfg.HistorySaveInterval = time.Duration(99)*time.Second if !reflect.DeepEqual(cfg, eCfg) { t.Log(eCfg) diff --git a/config/test_data.txt b/config/test_data.txt index a593f28f7..2636b4474 100644 --- a/config/test_data.txt +++ b/config/test_data.txt @@ -47,8 +47,11 @@ enabled = true # Start the CDR Server service: . listen=test # CDRS's listening interface: . extra_fields = test # Extra fields to store in CDRs mediator = test # Address where to reach the Mediator. Empty for disabling mediation. <""|internal> -export_path = test # Path where exported cdrs will be written -export_extra_fields = test # Extra fields list to be exported + +[cdre] +cdr_format = test # Exported CDRs format +extra_fields = test # List of extra fields to be exported out in CDRs +export_dir = test # Path where the exported CDRs will be placed [cdrc] enabled = true # Enable CDR client functionality @@ -102,7 +105,7 @@ reconnects = 99 # Number of attempts on connect failure. [history_server] enabled = true # Starts History service: . listen = test # Listening addres for history server: -path = test # Location on disk where to store history files. +history_dir = test # Location on disk where to store history files. save_interval = 99 # Timeout duration between saves [history_agent] diff --git a/data/conf/cgrates.cfg b/data/conf/cgrates.cfg index 5e6fe1033..db0189649 100644 --- a/data/conf/cgrates.cfg +++ b/data/conf/cgrates.cfg @@ -49,8 +49,11 @@ # listen=127.0.0.1:2022 # CDRS's listening interface: . # extra_fields = # Extra fields to store in CDRs # mediator = # Address where to reach the Mediator. Empty for disabling mediation. <""|internal> -# export_path = /var/log/cgrates/cdr/out/cgr # Path where the exported CDRs will be placed -# export_extra_fields = # List of extra fields to be exported out in CDRs + +[cdre] +# cdr_format = csv # Exported CDRs format +# extra_fields = # List of extra fields to be exported out in CDRs +# export_dir = /var/log/cgrates/cdr/out/cgr # Path where the exported CDRs will be placed [cdrc] # enabled = false # Enable CDR client functionality @@ -104,7 +107,7 @@ [history_server] # enabled = false # Starts History service: . # listen = 127.0.0.1:2013 # Listening addres for history server: -# path = /var/log/cgrates/history # Location on disk where to store history files. +# history_dir = /var/log/cgrates/history # Location on disk where to store history files. # save_interval = 1s # Interval to save changed cache into .git archive [history_agent] diff --git a/docs/history.rst b/docs/history.rst index ef3a3c12f..840a668ae 100644 --- a/docs/history.rst +++ b/docs/history.rst @@ -21,9 +21,10 @@ Functionality: - When receiving rating information from the agents it will recompile the cache. - Based on configured save interval it will dump the rating cache (if changed) into the .git archive. - Archives the following rating data: - - Destinations inside *destinations.json* file. - - Rating plans inside *rating_plans.json* file. - - Rating profiles inside *rating_profiles.json* file. + + - Destinations inside *destinations.json* file. + - Rating plans inside *rating_plans.json* file. + - Rating profiles inside *rating_profiles.json* file. History-Agent -------------