CdrE config, documentation fixup

This commit is contained in:
DanB
2013-12-31 11:57:19 +01:00
parent 4092baea56
commit 9f45635de0
7 changed files with 45 additions and 31 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -89,8 +89,9 @@ type CGRConfig struct {
CDRSListen string // CDRS's listening interface: <x.y.z.y:1234>.
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. <csv>
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 <http_cgr>
@@ -136,7 +137,7 @@ type CGRConfig struct {
HistoryServer string // Address where to reach the master history server: <internal|x.y.z.y:1234>
HistoryServerEnabled bool // Starts History as server: <true|false>.
HistoryListen string // History server listening interface: <internal|x.y.z.y:1234>
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")

View File

@@ -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)

View File

@@ -47,8 +47,11 @@ enabled = true # Start the CDR Server service: <true|false>.
listen=test # CDRS's listening interface: <x.y.z.y:1234>.
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 <csv>
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: <true|false>.
listen = test # Listening addres for history server: <internal|x.y.z.y:1234>
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]

View File

@@ -49,8 +49,11 @@
# listen=127.0.0.1:2022 # CDRS's listening interface: <x.y.z.y:1234>.
# 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 <csv>
# 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: <true|false>.
# listen = 127.0.0.1:2013 # Listening addres for history server: <internal|x.y.z.y:1234>
# 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]

View File

@@ -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
-------------