diff --git a/apier/cdrstatsv1.go b/apier/cdrstatsv1.go new file mode 100644 index 000000000..2074f2308 --- /dev/null +++ b/apier/cdrstatsv1.go @@ -0,0 +1,41 @@ +/* +Real-time Charging System for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can Storagetribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITH*out ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package apier + +import ( + "fmt" + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +// Interact with Stats server +type CDRStatsV1 struct { + CdrSts *engine.Stats +} + +type AttrGetMetrics struct { + StatsInstanceId string // Id of the stats instance queried +} + +func (sts *CDRStatsV1) GetMetrics(attr AttrGetMetrics, reply *map[string]float64) error { + if len(attr.StatsInstanceId) == 0 { + return fmt.Errorf("%s:StatsInstanceId", utils.ERR_MANDATORY_IE_MISSING) + } + return sts.CdrSts.GetValues(attr.StatsInstanceId, reply) +} diff --git a/config/cdrstatsconfig.go b/config/cdrstatsconfig.go new file mode 100644 index 000000000..a6a6ab10c --- /dev/null +++ b/config/cdrstatsconfig.go @@ -0,0 +1,53 @@ +/* +Real-time Charging System for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package config + +import ( + "code.google.com/p/goconf/conf" + "time" +) + +// Parse the configuration file for CDRStatConfigs +func ParseCfgCDRStatConfigs(c *conf.ConfigFile) ([]*CdrStatsConfig, error) { + return nil, nil +} + +type CdrStatsConfig struct { + Id string // Config id, unique per config instance + QueueLength int // Number of items in the stats buffer + TimeWindow time.Duration // Will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow + Metrics []string // ASR, ACD, ACC + SetupInterval []time.Time // 2 or less items (>= start interval,< stop_interval) + TOR []string + CdrHost []string + CdrSource []string + ReqType []string + Direction []string + Tenant []string + Category []string + Account []string + Subject []string + DestinationPrefix []string + UsageInterval []time.Duration // 2 or less items (>= Usage, =Cost, . [cdrs] enabled = true # Start the CDR Server service: . extra_fields = test # Extra fields to scategorye in CDRs -mediator = test # Address where to reach the Mediacategory. Empty for disabling mediation. <""|internal> -stats = test # Address where to reach the stats sevre. Empty for disabling stats. <""|internal> - -[stats] -enabled = true # Start the CDR stats service: . +mediator = test # Address where to reach the Mediator. Empty for disabling mediation. <""|internal> +cdrstats = test # Address where to reach the CDRStats server. Empty for disabling stats. <""|internal> [cdre] cdr_format = test # Exported CDRs format @@ -87,8 +84,30 @@ extra_fields = test:test # Field identifiers of the fields to add in extra field [mediator] enabled = true # Starts Mediacategory service: . rater = test # Address where to reach the Rater: -reconnects = 99 # Number of reconnects to rater before giving up. -stats = test # Address where to reach the stats service: +reconnects = 99 # Number of reconnects to rater before giving up. +cdrstats = test # Address where to reach the cdrstats service: + +[cdrstats] +enabled = true # Start the CDR stats service: . +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_intervals =test # 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 +req_types = test # Filter on CDR ReqType fields +directions = test # Filter on CDR Direction fields +tenants = test # Filter on CDR Tenant fields +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_intervals = test # Filter on CDR Usage +mediation_runs = test # Filter on CDR MediationRunId fields +rated_accounts = test # Filter on CDR RatedAccount fields +rated_subjects = test # Filter on CDR RatedSubject fields +cost_intervals = test # Filter on CDR Cost [session_manager] enabled = true # Starts SessionManager service: . diff --git a/data/conf/cgrates.cfg b/data/conf/cgrates.cfg index b4a117534..15b07c24b 100644 --- a/data/conf/cgrates.cfg +++ b/data/conf/cgrates.cfg @@ -88,6 +88,30 @@ # enabled = false # Starts Mediator service: . # rater = internal # Address where to reach the Rater: # rater_reconnects = 3 # Number of reconnects to rater before giving up. +# cdrstats = # Address where to reach the cdrstats service: + +[cdrstats] +# enabled = false # Starts the cdrstats service: +# queue_length = 50 # Number of items in the stats buffer +# time_window = 1h # Will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow +# metrics = ASR, ACD, ACC # Stat metric ids to build +# setup_intervals = # Filter on CDR SetupTime +# tors = # Filter on CDR TOR fields +# cdr_hosts= # Filter on CDR CdrHost fields +# cdr_sources = # Filter on CDR CdrSource fields +# req_types = # Filter on CDR ReqType fields +# directions = # Filter on CDR Direction fields +# tenants = # Filter on CDR Tenant fields +# categories = # Filter on CDR Category fields +# accounts = # Filter on CDR Account fields +# subjects = # Filter on CDR Subject fields +# destination_prefixes = # Filter on CDR Destination prefixes +# usage_intervals = # Filter on CDR Usage +# mediation_runs = # Filter on CDR MediationRunId fields +# rated_accounts = # Filter on CDR RatedAccount fields +# rated_subjects = # Filter on CDR RatedSubject fields +# cost_intervals = # Filter on CDR Cost + [session_manager] # enabled = false # Starts SessionManager service: