diff --git a/config/config.go b/config/config.go index 49c227c92..0e4ce9aae 100644 --- a/config/config.go +++ b/config/config.go @@ -64,6 +64,7 @@ type CGRConfig struct { BalancerEnabled bool BalancerListen string // Json RPC server address SchedulerEnabled bool + CDRSEnabled bool // Enable CDR Server service CDRSListen string // CDRS's listening interface: . CDRSfsJSONEnabled bool // Enable the handler for FreeSWITCH JSON CDRs: . CDRSgenJSONEnabled bool // Enable the handler for Generic JSON CDRs: . @@ -127,6 +128,7 @@ func (self *CGRConfig) setDefaults() error { self.BalancerEnabled = false self.BalancerListen = "127.0.0.1:2013" self.SchedulerEnabled = false + self.CDRSEnabled = false self.CDRSListen = "127.0.0.1:2022" self.CDRSfsJSONEnabled = false self.CDRSgenJSONEnabled = false @@ -269,6 +271,9 @@ func loadConfig(c *conf.ConfigFile) (*CGRConfig, error) { if hasOpt = c.HasOption("scheduler", "enabled"); hasOpt { cfg.SchedulerEnabled, _ = c.GetBool("scheduler", "enabled") } + if hasOpt = c.HasOption("cdrs", "enabled"); hasOpt { + cfg.CDRSEnabled, _ = c.GetBool("cdrs", "enabled") + } if hasOpt = c.HasOption("cdrs", "listen"); hasOpt { cfg.CDRSListen, _ = c.GetString("cdrs", "listen") } diff --git a/config/config_test.go b/config/config_test.go index 1ab755a3e..97d273c55 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -59,6 +59,7 @@ func TestDefaults(t *testing.T) { eCfg.BalancerEnabled = false eCfg.BalancerListen = "127.0.0.1:2013" eCfg.SchedulerEnabled = false + eCfg.CDRSEnabled = false eCfg.CDRSListen = "127.0.0.1:2022" eCfg.CDRSfsJSONEnabled = false eCfg.CDRSgenJSONEnabled = false @@ -155,6 +156,7 @@ func TestConfigFromFile(t *testing.T) { eCfg.BalancerEnabled = true eCfg.BalancerListen = "test" eCfg.SchedulerEnabled = true + eCfg.CDRSEnabled = true eCfg.CDRSListen = "test" eCfg.CDRSfsJSONEnabled = true eCfg.CDRSgenJSONEnabled = true diff --git a/config/test_data.txt b/config/test_data.txt index f7ce00870..95a552c87 100644 --- a/config/test_data.txt +++ b/config/test_data.txt @@ -36,6 +36,7 @@ listen = test # Rater's listening interface: . enabled = true # Starts Scheduler service: . [cdrs] +enabled = true # Start the CDR Server service: . listen=test # CDRS's listening interface: . freeswitch_json_enabled=true # Enable the handler for FreeSWITCH JSON CDRs: . generic_json_enabled=true # Enable the handler for generic JSON CDRs: . @@ -80,4 +81,4 @@ server = test # Address where to reach the master history server: . listen = test # Listening addres for history server: -path = test # Location on disk where to store history files. \ No newline at end of file +path = test # Location on disk where to store history files. diff --git a/data/conf/cgrates.cfg b/data/conf/cgrates.cfg index 447db28d8..881fe63c7 100644 --- a/data/conf/cgrates.cfg +++ b/data/conf/cgrates.cfg @@ -8,18 +8,18 @@ # datadb_type = redis # The main database: . # datadb_host = 127.0.0.1 # Database host address. # datadb_port = 6379 # Port to reach the database. -# datadb_name = 10 # The name of the database to connect to. -# datadb_user = # Username to use when connecting to database. -# datadb_passwd = # Password to use when connecting to database. +# datadb_name = 10 # The name of the database to connect to. +# datadb_user = # Username to use when connecting to database. +# datadb_passwd = # Password to use when connecting to database. # stordb_type = mysql # Log/stored database type to use: # stordb_host = 127.0.0.1 # The host to connect to. Values that start with / are for UNIX domain sockets. # stordb_port = 3306 # The port to reach the logdb. # stordb_name = cgrates # The name of the log database to connect to. # stordb_user = cgrates # Username to use when connecting to stordb. -# stordb_passwd = CGRateS.org # Password to use when connecting to stordb. +# stordb_passwd = CGRateS.org # Password to use when connecting to stordb. # rpc_encoding = json # RPC encoding used on APIs: . # default_reqtype = rated # Default request type to consider when missing from requests: <""|prepaid|postpaid|pseudoprepaid|rated>. -# default_tor = 0 # Default Type of Record to consider when missing from requests. +# default_tor = 0 # Default Type of Record to consider when missing from requests. # default_tenant = 0 # Default Tenant to consider when missing from requests. # default_subject = 0 # Default rating Subject to consider when missing from requests. # rounding_method = *middle # Rounding method for floats/costs: <*up|*middle|*down> @@ -27,59 +27,59 @@ [balancer] -# enabled = false # Start Balancer service: . +# enabled = false # Start Balancer service: . # listen = 127.0.0.1:2012 # Balancer listen interface: . [rater] -# enabled = false # Enable Rater service: . +# enabled = false # Enable Rater service: . # balancer = disabled # Register to Balancer as worker: . # listen = 127.0.0.1:2012 # Rater's listening interface: . [scheduler] -# enabled = false # Starts Scheduler service: . +# enabled = false # Starts Scheduler service: . [cdrs] -# listen=127.0.0.1:2022 # CDRS's listening interface: . +# listen=127.0.0.1:2022 # CDRS's listening interface: . # freeswitch_json_enabled=false # Enable the handler for FreeSWITCH JSON CDRs: . -# mediator = # Address where to reach the Mediator. Empty for disabling mediation. <""|internal> -# extra_fields = # Extra fields to store in CDRs +# mediator = # Address where to reach the Mediator. Empty for disabling mediation. <""|internal> +# extra_fields = # Extra fields to store in CDRs [mediator] -# enabled = false # Starts Mediator service: . -# listen=internal # Mediator's listening interface: . -# rater = 127.0.0.1:2012 # Address where to reach the Rater: -# rater_reconnects = 3 # Number of reconnects to rater before giving up. -# cdr_type = freeswitch_http_json # CDR type . -# accid_field = accid # Name of field identifying accounting id used during mediation. Use index number in case of .csv cdrs. -# subject_fields = subject # Name of subject fields to be used during mediation. Use index numbers in case of .csv cdrs. -# reqtype_fields = reqtype # Name of request type fields to be used during mediation. Use index number in case of .csv cdrs. -# direction_fields = direction # Name of direction fields to be used during mediation. Use index numbers in case of .csv cdrs. -# tenant_fields = tenant # Name of tenant fields to be used during mediation. Use index numbers in case of .csv cdrs. -# tor_fields = tor # Name of tor fields to be used during mediation. Use index numbers in case of .csv cdrs. -# account_fields = account # Name of account fields to be used during mediation. Use index numbers in case of .csv cdrs. -# destination_fields = destination # Name of destination fields to be used during mediation. Use index numbers in case of .csv cdrs. -# time_answer_fields = time_answer # Name of time_answer fields to be used during mediation. Use index numbers in case of .csv cdrs. -# duration_fields = duration # Name of duration fields to be used during mediation. Use index numbers in case of .csv cdrs. -# cdr_in_dir = /var/log/freeswitch/cdr-csv # Absolute path towards the directory where the CDRs are kept (file stored CDRs). -# cdr_out_dir = /var/log/cgrates/cdr/out/freeswitch/csv # Absolute path towards the directory where processed CDRs will be exported (file stored CDRs). +# enabled = false # Starts Mediator service: . +# listen=internal # Mediator's listening interface: . +# rater = 127.0.0.1:2012 # Address where to reach the Rater: +# rater_reconnects = 3 # Number of reconnects to rater before giving up. +# cdr_type = freeswitch_http_json # CDR type . +# accid_field = accid # Name of field identifying accounting id used during mediation. Use index number in case of .csv cdrs. +# subject_fields = subject # Name of subject fields to be used during mediation. Use index numbers in case of .csv cdrs. +# reqtype_fields = reqtype # Name of request type fields to be used during mediation. Use index number in case of .csv cdrs. +# direction_fields = direction # Name of direction fields to be used during mediation. Use index numbers in case of .csv cdrs. +# tenant_fields = tenant # Name of tenant fields to be used during mediation. Use index numbers in case of .csv cdrs. +# tor_fields = tor # Name of tor fields to be used during mediation. Use index numbers in case of .csv cdrs. +# account_fields = account # Name of account fields to be used during mediation. Use index numbers in case of .csv cdrs. +# destination_fields = destination # Name of destination fields to be used during mediation. Use index numbers in case of .csv cdrs. +# time_answer_fields = time_answer # Name of time_answer fields to be used during mediation. Use index numbers in case of .csv cdrs. +# duration_fields = duration # Name of duration fields to be used during mediation. Use index numbers in case of .csv cdrs. +# cdr_in_dir = /var/log/freeswitch/cdr-csv # Absolute path towards the directory where the CDRs are kept (file stored CDRs). +# cdr_out_dir = /var/log/cgrates/cdr/out/freeswitch/csv # Absolute path towards the directory where processed CDRs will be exported (file stored CDRs). [session_manager] -# enabled = false # Starts SessionManager service: . -# switch_type = freeswitch # Defines the type of switch behind: . -# rater = 127.0.0.1:2012 # Address where to reach the Rater. -# rater_reconnects = 3 # Number of reconnects to rater before giving up. -# debit_interval = 5 # Interval to perform debits on. +# enabled = false # Starts SessionManager service: . +# switch_type = freeswitch # Defines the type of switch behind: . +# rater = 127.0.0.1:2012 # Address where to reach the Rater. +# rater_reconnects = 3 # Number of reconnects to rater before giving up. +# debit_interval = 5 # Interval to perform debits on. [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. +# 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. [history_agent] -#enabled = false # Starts History as a client: . -#server = 127.0.0.1:2013 # Address where to reach the master history server: +#enabled = false # Starts History as a client: . +#server = 127.0.0.1:2013 # Address where to reach the master history server: [history_server] -#enabled = false # Starts History service: . -#listen = 127.0.0.1:2013 # Listening addres for 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. diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 84216ee7a..6257a54a5 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -828,7 +828,7 @@ func (self *SQLStorage) LogCallCost(uuid, source string, cc *CallCost) (err erro if err != nil { Logger.Err(fmt.Sprintf("Error marshalling timespans to json: %v", err)) } - _, err = self.Db.Exec(fmt.Sprintf("INSERT INTO %s (cgrid, accid, direction, tenant, tor, account, subject, destination, cost, connect_fee, timespans, source )VALUES ('%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', %f, %f, '%s','%s')", + _, err = self.Db.Exec(fmt.Sprintf("INSERT INTO %s (cgrid, accid, direction, tenant, tor, account, subject, destination, cost, connect_fee, timespans, source )VALUES ('%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', %f, %f, '%s','%s')", utils.TBL_COST_DETAILS, utils.FSCgrId(uuid), uuid,