mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Paginator parameters rename
This commit is contained in:
@@ -115,7 +115,13 @@ func (self *ApierV1) GetScheduledActions(attrs AttrsGetScheduledActions, reply *
|
||||
return errors.New("SCHEDULER_NOT_ENABLED")
|
||||
}
|
||||
scheduledActions := self.Sched.GetQueue()
|
||||
min, max := attrs.GetLimits()
|
||||
var min, max int
|
||||
if attrs.Paginator.Offset != nil {
|
||||
min = *attrs.Paginator.Offset
|
||||
}
|
||||
if attrs.Paginator.Limit != nil {
|
||||
max = *attrs.Paginator.Limit
|
||||
}
|
||||
if max > len(scheduledActions) {
|
||||
max = len(scheduledActions)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
cfgDir = flag.String("config_dir", "/etc/cgrates", "Configuration directory path.")
|
||||
cfgDir = flag.String("config_dir", utils.CONFIG_DIR, "Configuration directory path.")
|
||||
version = flag.Bool("version", false, "Prints the application version.")
|
||||
raterEnabled = flag.Bool("rater", false, "Enforce starting of the rater daemon overwriting config")
|
||||
schedEnabled = flag.Bool("scheduler", false, "Enforce starting of the scheduler daemon .overwriting config")
|
||||
|
||||
@@ -96,43 +96,46 @@ func NewCGRConfigFromJsonString(cfgJsonStr string) (*CGRConfig, error) {
|
||||
|
||||
// Reads all .json files out of a folder/subfolders and loads them up in lexical order
|
||||
func NewCGRConfigFromFolder(cfgDir string) (*CGRConfig, error) {
|
||||
if fi, err := os.Stat(cfgDir); err != nil {
|
||||
return nil, err
|
||||
} else if !fi.IsDir() {
|
||||
return nil, fmt.Errorf("Path: %s not a directory.", cfgDir)
|
||||
}
|
||||
cfg, err := NewDefaultCGRConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
jsonFilesFound := false
|
||||
err = filepath.Walk(cfgDir, func(path string, info os.FileInfo, err error) error {
|
||||
if !info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
cfgFiles, err := filepath.Glob(filepath.Join(path, "*.json"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cfgFiles == nil { // No need of processing further since there are no config files in the folder
|
||||
return nil
|
||||
}
|
||||
if !jsonFilesFound {
|
||||
jsonFilesFound = true
|
||||
}
|
||||
for _, jsonFilePath := range cfgFiles {
|
||||
if cgrJsonCfg, err := NewCgrJsonCfgFromFile(jsonFilePath); err != nil {
|
||||
return err
|
||||
} else if err := cfg.loadFromJsonCfg(cgrJsonCfg); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
fi, err := os.Stat(cfgDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !jsonFilesFound {
|
||||
return nil, fmt.Errorf("No config file found on path %s", cfgDir)
|
||||
} else if !fi.IsDir() && cfgDir != utils.CONFIG_DIR { // If config dir defined, needs to exist, not checking for default
|
||||
return nil, fmt.Errorf("Path: %s not a directory.", cfgDir)
|
||||
}
|
||||
if fi.IsDir() {
|
||||
jsonFilesFound := false
|
||||
err = filepath.Walk(cfgDir, func(path string, info os.FileInfo, err error) error {
|
||||
if !info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
cfgFiles, err := filepath.Glob(filepath.Join(path, "*.json"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cfgFiles == nil { // No need of processing further since there are no config files in the folder
|
||||
return nil
|
||||
}
|
||||
if !jsonFilesFound {
|
||||
jsonFilesFound = true
|
||||
}
|
||||
for _, jsonFilePath := range cfgFiles {
|
||||
if cgrJsonCfg, err := NewCgrJsonCfgFromFile(jsonFilePath); err != nil {
|
||||
return err
|
||||
} else if err := cfg.loadFromJsonCfg(cgrJsonCfg); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !jsonFilesFound {
|
||||
return nil, fmt.Errorf("No config file found on path %s", cfgDir)
|
||||
}
|
||||
}
|
||||
if err := cfg.checkConfigSanity(); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -239,4 +239,4 @@
|
||||
// "from_address": "cgr-mailer@localhost.localdomain" // from address used when sending emails out
|
||||
//},
|
||||
|
||||
//}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ set -e
|
||||
case "$1" in
|
||||
|
||||
configure)
|
||||
adduser --quiet --system --group --disabled-password --shell /bin/false --home /var/run/cgrates --gecos "CGRateS" cgrates || true
|
||||
adduser --quiet --system --group --disabled-password --shell /bin/false --gecos "CGRateS" cgrates || true
|
||||
chown -R cgrates:cgrates /var/log/cgrates/
|
||||
chown -R cgrates:cgrates /usr/share/cgrates/
|
||||
;;
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#Tenant,Account,Direction,ActionPlanTag,ActionTriggersTag
|
||||
cgrates.org,1001,*out,PREPAID_10,STANDARD_TRIGGERS
|
||||
cgrates.org,1002,*out,PREPAID_10,STANDARD_TRIGGERS
|
||||
cgrates.org,1003,*out,PREPAID_10,STANDARD_TRIGGERS
|
||||
cgrates.org,1004,*out,PREPAID_10,STANDARD_TRIGGERS
|
||||
|
@@ -1,2 +0,0 @@
|
||||
#Tag,ActionsTag,TimingTag,Weight
|
||||
PREPAID_10,PREPAID_10,ASAP,10
|
||||
|
@@ -1,4 +0,0 @@
|
||||
#Tag,BalanceTag,Direction,ThresholdType,ThresholdValue,Recurrent,MinSleep,BalanceDestinationTag,BalanceWeight,BalanceExpiryTime,BalanceRatingSubject,BalanceSharedGroup,StatsMinQueuedItems,ActionsTag,Weight
|
||||
STANDARD_TRIGGERS,*monetary,*out,*min_balance,2,false,0,,,,,,,LOG_WARNING,10
|
||||
STANDARD_TRIGGERS,*monetary,*out,*max_balance,20,false,0,,,,,,,LOG_WARNING,10
|
||||
STANDARD_TRIGGERS,*monetary,*out,*max_counter,5,false,0,FS_USERS,,,,,,LOG_WARNING,10
|
||||
|
@@ -1,3 +0,0 @@
|
||||
#ActionsTag,Action,BalanceType,Direction,Units,ExpiryTime,DestinationTag,RatingSubject,BalanceWeight,SharedGroup,ExtraParameters,Weight
|
||||
PREPAID_10,*topup_reset,*monetary,*out,10,*unlimited,*any,,10,,,10
|
||||
LOG_WARNING,*log,,,,,,,,,,10
|
||||
|
@@ -1,4 +0,0 @@
|
||||
#Tag,DestinationsTag,RatesTag,RoundingMethod,RoundingDecimals
|
||||
DR_RETAIL,DST_1002,RT_20CNT,*up,4
|
||||
DR_RETAIL,DST_1003,RT_40CNT,*up,4
|
||||
DR_RETAIL,DST_FS,RT_10CNT,*up,4
|
||||
|
@@ -1,4 +0,0 @@
|
||||
#Tag,Prefix
|
||||
DST_1002,1002
|
||||
DST_1003,1003
|
||||
DST_FS,10
|
||||
|
@@ -1,14 +0,0 @@
|
||||
Tutorial - FS_CSV
|
||||
=================
|
||||
|
||||
Scenario:
|
||||
---------
|
||||
|
||||
* Create the necessary timings (always, asap).
|
||||
* Configure 1 destination: FS_USERS.
|
||||
* Calls to FreeSWITCH users will be rated with 10cents per minute for the first 60s(60s increments) then 5 cents per minute(1s increments).
|
||||
* This rating profile will be valid for any rating subject.
|
||||
|
||||
* Create 2 prepaid accounts (equivalent of 2 FreeSWITCH default test users - 1001, 1002).
|
||||
* Add to each of the accounts a monetary balance of 10 units.
|
||||
* For each balance created, attach 3 triggers to control the balance: log on balance=2, log on balance=20, log on 5 mins talked towards FS_USERS destination.
|
||||
@@ -1,7 +0,0 @@
|
||||
#Tag,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart
|
||||
RT_10CNT,0.2,0.1,60s,60s,0s
|
||||
RT_10CNT,0,0.05,60s,1s,60s
|
||||
RT_20CNT,0.4,0.2,60s,60s,0s
|
||||
RT_20CNT,0,0.1,60s,1s,60s
|
||||
RT_40CNT,0.8,0.4,60s,30s,0s
|
||||
RT_40CNT,0,0.2,60s,10s,60s
|
||||
|
@@ -1,2 +0,0 @@
|
||||
#Tag,DestinationRatesTag,TimingTag,Weight
|
||||
RP_RETAIL,DR_RETAIL,ALWAYS,10
|
||||
|
@@ -1,2 +0,0 @@
|
||||
#Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject
|
||||
*out,cgrates.org,call,*any,2013-01-06T00:00:00Z,RP_RETAIL,
|
||||
|
@@ -1,3 +0,0 @@
|
||||
#Tag,Years,Months,MonthDays,WeekDays,Time
|
||||
ALWAYS,*any,*any,*any,*any,00:00:00
|
||||
ASAP,*any,*any,*any,*any,*asap
|
||||
|
@@ -1,174 +0,0 @@
|
||||
# Real-time Charging System for Telecom & ISP environments
|
||||
# Copyright (C) ITsysCOM GmbH
|
||||
#
|
||||
# This file contains the default configuration hardcoded into CGRateS.
|
||||
# This is what you get when you load CGRateS with an empty configuration file.
|
||||
|
||||
[global]
|
||||
# ratingdb_type = redis # Rating subsystem database: <redis>.
|
||||
# ratingdb_host = 127.0.0.1 # Rating subsystem database host address.
|
||||
# ratingdb_port = 6379 # Rating subsystem port to reach the database.
|
||||
# ratingdb_name = 10 # Rating subsystem database name to connect to.
|
||||
# ratingdb_user = # Rating subsystem username to use when connecting to database.
|
||||
# ratingdb_passwd = # Rating subsystem password to use when connecting to database.
|
||||
# accountdb_type = redis # Accounting subsystem database: <redis>.
|
||||
# accountdb_host = 127.0.0.1 # Accounting subsystem database host address.
|
||||
# accountdb_port = 6379 # Accounting subsystem port to reach the database.
|
||||
# accountdb_name = 11 # Accounting subsystem database name to connect to.
|
||||
# accountdb_user = # Accounting subsystem username to use when connecting to database.
|
||||
# accountdb_passwd = # Accounting subsystem password to use when connecting to database.
|
||||
# stordb_type = mysql # Stor database type to use: <mysql>
|
||||
# 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.
|
||||
# dbdata_encoding = msgpack # The encoding used to store object data in strings: <msgpack|json>
|
||||
# rpc_json_listen = 127.0.0.1:2012 # RPC JSON listening address
|
||||
# rpc_gob_listen = 127.0.0.1:2013 # RPC GOB listening address
|
||||
# http_listen = 127.0.0.1:2080 # HTTP listening address
|
||||
# default_reqtype = rated # Default request type to consider when missing from requests: <""|prepaid|postpaid|pseudoprepaid|rated>.
|
||||
# default_category = call # Default Type of Record to consider when missing from requests.
|
||||
# default_tenant = cgrates.org # Default Tenant to consider when missing from requests.
|
||||
# default_subject = cgrates # Default rating Subject to consider when missing from requests.
|
||||
# rounding_decimals = 10 # System level precision for floats
|
||||
# http_skip_tls_veify = false # If enabled Http Client will accept any TLS certificate
|
||||
# xmlcfg_path = # Path towards additional config defined in xml file
|
||||
|
||||
[balancer]
|
||||
# enabled = false # Start Balancer service: <true|false>.
|
||||
|
||||
[rater]
|
||||
enabled = true # Enable RaterCDRSExportPath service: <true|false>.
|
||||
# balancer = # Register to Balancer as worker: <""|internal|127.0.0.1:2013>.
|
||||
|
||||
[scheduler]
|
||||
enabled = true # Starts Scheduler service: <true|false>.
|
||||
|
||||
[cdrs]
|
||||
enabled = true # Start the CDR Server service: <true|false>.
|
||||
# extra_fields = # Extra fields to store in CDRs for non-generic CDRs
|
||||
mediator = internal # Address where to reach the Mediator. Empty for disabling mediation. <""|internal>
|
||||
# cdrstats = # Address where to reach the cdrstats service: <internal|x.y.z.y:1234>
|
||||
# store_disable = false # When true, CDRs will not longer be saved in stordb, useful for cdrstats only scenario
|
||||
|
||||
[cdre]
|
||||
# cdr_format = csv # Exported CDRs format <csv>
|
||||
# data_usage_multiply_factor = 0.0 # Multiply data usage before export (eg: convert from KBytes to Bytes)
|
||||
# cost_multiply_factor = 0.0 # Multiply cost before export (0.0 to disable), eg: add VAT
|
||||
# cost_rounding_decimals = -1 # Rounding decimals for Cost values. -1 to disable rounding
|
||||
# cost_shift_digits = 0 # Shift digits in the cost on export (eg: convert from EUR to cents)
|
||||
# mask_destination_id = # Destination id containing called addresses to be masked on export
|
||||
# mask_length = 0 # Length of the destination suffix to be masked
|
||||
export_dir = /tmp/cgrates/cdre # Path where the exported CDRs will be placed
|
||||
# export_template = cgrid,mediation_runid,tor,accid,reqtype,direction,tenant,category,account,subject,destination,setup_time,answer_time,usage,cost
|
||||
# Exported fields template <""|fld1,fld2|*xml:instance_name>
|
||||
[cdrc]
|
||||
# enabled = false # Enable CDR client functionality
|
||||
# cdrs = internal # Address where to reach CDR server. <internal|127.0.0.1:2080>
|
||||
# run_delay = 0 # Sleep interval in seconds between consecutive runs, 0 to use automation via inotify
|
||||
# cdr_type = csv # CDR file format <csv|freeswitch_csv>.
|
||||
# csv_separator = , # Separator used in case of csv files. One character only supported and needs to be right after equal sign
|
||||
# cdr_in_dir = /var/log/cgrates/cdrc/in # Absolute path towards the directory where the CDRs are stored.
|
||||
# cdr_out_dir = /var/log/cgrates/cdrc/out # Absolute path towards the directory where processed CDRs will be moved.
|
||||
# cdr_source_id = csv # Free form field, tag identifying the source of the CDRs within CGRS database.
|
||||
# tor_field = 2 # TypeOfRecord field identifier. Use index number in case of .csv cdrs.
|
||||
# accid_field = 3 # Accounting id field identifier. Use index number in case of .csv cdrs.
|
||||
# reqtype_field = 4 # Request type field identifier. Use index number in case of .csv cdrs.
|
||||
# direction_field = 5 # Direction field identifier. Use index numbers in case of .csv cdrs.
|
||||
# tenant_field = 6 # Tenant field identifier. Use index numbers in case of .csv cdrs.
|
||||
# category_field = 7 # Type of Record field identifier. Use index numbers in case of .csv cdrs.
|
||||
# account_field = 8 # Account field identifier. Use index numbers in case of .csv cdrs.
|
||||
# subject_field = 9 # Subject field identifier. Use index numbers in case of .csv CDRs.
|
||||
# destination_field = 10 # Destination field identifier. Use index numbers in case of .csv cdrs.
|
||||
# setup_time_field = 11 # Setup time field identifier. Use index numbers in case of .csv cdrs.
|
||||
# answer_time_field = 12 # Answer time field identifier. Use index numbers in case of .csv cdrs.
|
||||
# usage_field = 13 # Usage field identifier. Use index numbers in case of .csv cdrs.
|
||||
# extra_fields = # Extra fields identifiers. For .csv, format: <label_extrafield_1>:<index_extrafield_1>[...,<label_extrafield_n>:<index_extrafield_n>]
|
||||
|
||||
[mediator]
|
||||
enabled = true # Starts Mediator service: <true|false>.
|
||||
# reconnects = 3 # Number of reconnects to rater/cdrs before giving up.
|
||||
# rater = internal # Address where to reach the Rater: <internal|x.y.z.y:1234>
|
||||
# cdrstats = internal # Address where to reach the cdrstats service: <internal|x.y.z.y:1234>
|
||||
# store_disable = false # When true, CDRs will not longer be saved in stordb, useful for cdrstats only scenario
|
||||
|
||||
|
||||
[cdrstats]
|
||||
enabled = true # Starts the cdrstats service: <true|false>
|
||||
# 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_interval = # 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_interval = # Filter on CDR Usage
|
||||
# mediation_run_ids = # 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 = true # Starts SessionManager service: <true|false>
|
||||
# switch_type = freeswitch # Defines the type of switch behind: <freeswitch>
|
||||
# rater = internal # Address where to reach the Rater <""|internal|127.0.0.1:2013>
|
||||
cdrs = internal # Address where to reach CDR Server, empty to disable CDR capturing <""|internal|127.0.0.1:2013>
|
||||
# reconnects = 3 # Number of reconnects to rater/cdrs before giving up.
|
||||
debit_interval = 2 # Interval to perform debits on.
|
||||
# min_call_duration = 0s # Only authorize calls with allowed duration bigger than this
|
||||
# max_call_duration = 3h # Maximum call duration a prepaid call can last
|
||||
|
||||
[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.
|
||||
# min_dur_low_balance = 5s # Threshold which will trigger low balance warnings for prepaid calls (needs to be lower than debit_interval)
|
||||
# low_balance_ann_file = # File to be played when low balance is reached for prepaid calls
|
||||
# empty_balance_context = # If defined, prepaid calls will be transfered to this context on empty balance
|
||||
# empty_balance_ann_file = # File to be played before disconnecting prepaid calls on empty balance (applies only if no context defined)
|
||||
# cdr_extra_fields = # Extra fields to store in CDRs in case of processing them
|
||||
|
||||
[opensips]
|
||||
# listen_udp = 127.0.0.1:2020 # Address where to listen for datagram events coming from OpenSIPS
|
||||
# mi_addr = 127.0.0.1:8020 # Adress where to reach OpenSIPS mi_datagram module
|
||||
# events_subscribe_interval = 60s # Automatic events subscription to OpenSIPS, 0 to disable it
|
||||
# reconnects = 3 # Number of attempts on connect failure.
|
||||
|
||||
[derived_charging]
|
||||
# run_ids = # Identifiers of additional sessions control.
|
||||
# run_filters = # List of cdr field filters for each run.
|
||||
# reqtype_fields = # Name of request type fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# direction_fields = # Name of direction fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# tenant_fields = # Name of tenant fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# category_fields = # Name of tor fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# account_fields = # Name of account fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# subject_fields = # Name of fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# destination_fields = # Name of destination fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# setup_time_fields = # Name of setup_time fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# answer_time_fields = # Name of answer_time fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# usage_fields = # Name of usage fields to be used during additional sessions control <""|*default|field_name>.
|
||||
# combined_chargers = true # Combine accounts specific derived_chargers with server configured ones <true|false>.
|
||||
|
||||
[history_server]
|
||||
enabled = true # Starts History service: <true|false>.
|
||||
# history_dir = /tmp/cgrates/history # Location on disk where to store history files.
|
||||
# save_interval = 1s # Interval to save changed cache into .git archive
|
||||
|
||||
[history_agent]
|
||||
enabled = true # Starts History as a client: <true|false>.
|
||||
# server = internal # Address where to reach the master history server: <internal|x.y.z.y:1234>
|
||||
|
||||
[mailer]
|
||||
# server = localhost # The server to use when sending emails out
|
||||
# auth_user = cgrates # Authenticate to email server using this user
|
||||
# auth_passwd = CGRateS.org # Authenticate to email server with this password
|
||||
# from_address = cgr-mailer@localhost.localdomain # From address used when sending emails out
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# start CGRateS init.d script?
|
||||
# starts with "true"
|
||||
ENABLE=true
|
||||
ENABLE=false
|
||||
|
||||
# Start with specific user/group
|
||||
#USER=cgrates
|
||||
@@ -10,7 +10,7 @@ ENABLE=true
|
||||
|
||||
# what extra options to give cgrates binary?
|
||||
# See cgr-engine -h for options
|
||||
#ENGINE_OPTS=''
|
||||
#DAEMON_OPTS=''
|
||||
|
||||
# Don't forget to create an appropriate config file,
|
||||
# else the CGRateS system will not start.
|
||||
|
||||
@@ -14,20 +14,21 @@
|
||||
# Do NOT "set -e"
|
||||
|
||||
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
||||
RUNDIR=/tmp/$NAME/run
|
||||
PIDFILE=$RUNDIR/cgr-engine.pid
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="CGRateS real-time charging system"
|
||||
NAME=cgrates
|
||||
DAEMON=/usr/bin/cgr-engine
|
||||
USER=cgrates
|
||||
GROUP=cgrates
|
||||
TUTFOLDER=/usr/share/cgrates/tutorials/fs_json/cgrates
|
||||
ENGINE_OPTS="-config=$TUTFOLDER/etc/cgrates/cgrates.cfg"
|
||||
PIDFILE=/tmp/cgr-engine_tutfsjson.pid
|
||||
DAEMON_OPTS=""
|
||||
RUNDIR=/tmp/$NAME/run
|
||||
PIDFILE=$RUNDIR/cgr-engine.pid
|
||||
STACKTRACE=$RUNDIR/$NAME.strace
|
||||
SCRIPTNAME=$TUTFOLDER/etc/init.d/$NAME
|
||||
DEFAULTS=$TUTFOLDER/etc/default/$NAME
|
||||
ENABLE=false
|
||||
ENABLE=true
|
||||
TUTFOLDER=/usr/share/cgrates/tutorials/fs_json/cgrates
|
||||
ENGINE_OPTS="-config=$TUTFOLDER/etc/cgrates/cgrates.cfg"
|
||||
HISTDIR=/tmp/$NAME/history
|
||||
CDREDIR=/tmp/$NAME/cdre
|
||||
|
||||
@@ -53,7 +54,8 @@ fi
|
||||
# Install the run folder
|
||||
if [ ! -d $RUNDIR ]; then
|
||||
mkdir -p $RUNDIR
|
||||
chown $USER:$GROUP $RUNDIR
|
||||
touch $STACKTRACE
|
||||
chown -R $USER:$GROUP $RUNDIR
|
||||
fi
|
||||
# Install the cdre folder
|
||||
if [ ! -d $CDREDIR ]; then
|
||||
@@ -66,7 +68,6 @@ if [ ! -d $HISTDIR ]; then
|
||||
chown $USER:$GROUP $HISTDIR
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
@@ -76,11 +77,12 @@ do_start()
|
||||
# 0 if daemon has been started
|
||||
# 1 if daemon was already running
|
||||
# 2 if daemon could not be started
|
||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
||||
echo "\n### Started at:" `date`>>$STACKTRACE
|
||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test\
|
||||
|| return 1
|
||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --exec $DAEMON --chuid $USER:$GROUP --background -- \
|
||||
$ENGINE_OPTS \
|
||||
|| return 2
|
||||
start-stop-daemon --start --quiet --chuid $USER:$GROUP --make-pidfile --pidfile $PIDFILE --background\
|
||||
--startas /bin/bash -- -c "exec $DAEMON $DAEMON_OPTS >> $STACKTRACE 2>&1" \
|
||||
|| return 2
|
||||
}
|
||||
|
||||
#
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#Tenant,Account,Direction,ActionPlanTag,ActionTriggersTag
|
||||
cgrates.org,1001,*out,PACKAGE_10_SHARED_A_5,STANDARD_TRIGGERS
|
||||
cgrates.org,1002;1006,*out,PACKAGE_10,STANDARD_TRIGGERS
|
||||
cgrates.org,1003,*out,PACKAGE_10,STANDARD_TRIGGERS
|
||||
cgrates.org,1004,*out,PACKAGE_10,STANDARD_TRIGGERS
|
||||
cgrates.org,1007,*out,USE_SHARED_A,STANDARD_TRIGGERS
|
||||
|
@@ -1,5 +0,0 @@
|
||||
#Tag,ActionsTag,TimingTag,Weight
|
||||
PACKAGE_10,TOPUP_RST_10,ASAP,10
|
||||
PACKAGE_10_SHARED_A_5,TOPUP_RST_5,ASAP,10
|
||||
PACKAGE_10_SHARED_A_5,TOPUP_RST_SHARED_5,ASAP,10
|
||||
USE_SHARED_A,SHARED_A_0,ASAP,10
|
||||
|
@@ -1,4 +0,0 @@
|
||||
#Tag,BalanceTag,Direction,ThresholdType,ThresholdValue,Recurrent,MinSleep,BalanceDestinationTag,BalanceWeight,BalanceExpiryTime,BalanceRatingSubject,BalanceSharedGroup,StatsMinQueuedItems,ActionsTag,Weight
|
||||
STANDARD_TRIGGERS,*monetary,*out,*min_balance,2,false,0,,,,,,,LOG_WARNING,10
|
||||
STANDARD_TRIGGERS,*monetary,*out,*max_balance,20,false,0,,,,,,,LOG_WARNING,10
|
||||
STANDARD_TRIGGERS,*monetary,*out,*max_counter,5,false,0,FS_USERS,,,,,,LOG_WARNING,10
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#ActionsTag,Action,BalanceType,Direction,Units,ExpiryTime,DestinationTag,RatingSubject,BalanceWeight,SharedGroup,ExtraParameters,Weight
|
||||
TOPUP_RST_10,*topup_reset,*monetary,*out,10,*unlimited,*any,,10,,,10
|
||||
TOPUP_RST_5,*topup_reset,*monetary,*out,5,*unlimited,*any,,20,,,10
|
||||
TOPUP_RST_5,*topup_reset,*voice,*out,5,*unlimited,DST_1002,SPECIAL_1002,20,,,10
|
||||
TOPUP_RST_SHARED_5,*topup,*monetary,*out,5,*unlimited,*any,,10,SHARED_A,,10
|
||||
SHARED_A_0,*topup_reset,*monetary,*out,0,*unlimited,*any,,10,SHARED_A,,10
|
||||
LOG_WARNING,*log,,,,,,,,,,10
|
||||
|
@@ -1,2 +0,0 @@
|
||||
#Direction,Tenant,Category,Account,Subject,RunId,RunFilter,ReqTypeField,DirectionField,TenantField,TorField,AccountField,SubjectField,DestinationField,SetupTimeField,AnswerTimeField,UsageField
|
||||
*out,cgrates.org,call,1001,1001,fs_json_run,,^rated,*default,*default,*default,*default,^1002,*default,*default,*default,*default
|
||||
|
@@ -1,8 +0,0 @@
|
||||
#Tag,DestinationsTag,RatesTag,RoundingMethod,RoundingDecimals
|
||||
DR_1002_20CNT,DST_1002,RT_20CNT,*up,4
|
||||
DR_1002_10CNT,DST_1002,RT_10CNT,*up,4
|
||||
DR_1003_20CNT,DST_1003,RT_40CNT,*up,4
|
||||
DR_1003_10CNT,DST_1003,RT_10CNT,*up,4
|
||||
DR_FS_40CNT,DST_FS,RT_40CNT,*up,4
|
||||
DR_FS_10CNT,DST_FS,RT_10CNT,*up,4
|
||||
DR_SPECIAL_1002,DST_1002,RT_1CNT,*up,4
|
||||
|
@@ -1,4 +0,0 @@
|
||||
#Tag,Prefix
|
||||
DST_1002,1002
|
||||
DST_1003,1003
|
||||
DST_FS,10
|
||||
|
@@ -1,24 +0,0 @@
|
||||
Tutorial FS_JSON
|
||||
================
|
||||
|
||||
Scenario:
|
||||
---------
|
||||
|
||||
- Create the necessary timings (always, asap, peak, offpeak).
|
||||
- Configure 3 destinations (1002, 1003 and 10 used as catch all rule).
|
||||
- As rating we configure the following:
|
||||
|
||||
- Rate id: *RT_10CNT* with connect fee of 20cents, 10cents per minute for the first 60s in 60s increments followed by 5cents per minute in 1s increments.
|
||||
- Rate id: *RT_20CNT* with connect fee of 40cents, 20cents per minute for the first 60s in 60s increments, followed by 10 cents per minute charged in 1s increments.
|
||||
- Rate id: *RT_40CNT* with connect fee of 80cents, 40cents per minute for the first 60s in 60s increments, follwed by 20cents per minute charged in 10s increments.
|
||||
- Will charge by default *RT_40CNT* for all FreeSWITCH_ destinations during peak time (Monday-Friday 08:00-19:00) and *RT_10CNT* during offpeatimes (rest).
|
||||
- Account 1001 will receive a special *deal* for 1002 and 1003 destinations during peak times with *RT_20CNT*, otherwise same as default rating.
|
||||
|
||||
- Create 5 accounts (equivalent of FreeSWITCH default test users - 1001, 1002, 1003, 1004, 1007).
|
||||
- 1002, 1003, 1004 will receive 10units of *monetary balance.
|
||||
- 1001 will receive 5 units of general *monetary and 5 units of shared balance in the shared group *SHARED_A*.
|
||||
- 1007 will receive 0 units of shared balance in the shared group *SHARED_A*.
|
||||
- Define the shared balance *SHARED_A* with debit policy *highest.
|
||||
|
||||
- For each balance created, attach 3 triggers to control the balance: log on balance=2, log on balance=20, log on 5 mins talked towards 10xx destination.
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#Tag,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart
|
||||
RT_10CNT,0.2,0.1,60s,60s,0s
|
||||
RT_10CNT,0,0.05,60s,1s,60s
|
||||
RT_20CNT,0.4,0.2,60s,60s,0s
|
||||
RT_20CNT,0,0.1,60s,1s,60s
|
||||
RT_40CNT,0.8,0.4,60s,30s,0s
|
||||
RT_40CNT,0,0.2,60s,10s,60s
|
||||
RT_1CNT,0,0.01,60s,60s,0s
|
||||
|
@@ -1,18 +0,0 @@
|
||||
#Tag,DestinationRatesTag,TimingTag,Weight
|
||||
RP_RETAIL1,DR_FS_40CNT,PEAK,10
|
||||
RP_RETAIL1,DR_FS_10CNT,OFFPEAK_MORNING,10
|
||||
RP_RETAIL1,DR_FS_10CNT,OFFPEAK_EVENING,10
|
||||
RP_RETAIL1,DR_FS_10CNT,OFFPEAK_WEEKEND,10
|
||||
RP_RETAIL2,DR_1002_20CNT,PEAK,10
|
||||
RP_RETAIL2,DR_1003_20CNT,PEAK,10
|
||||
RP_RETAIL2,DR_FS_40CNT,PEAK,10
|
||||
RP_RETAIL2,DR_1002_10CNT,OFFPEAK_MORNING,10
|
||||
RP_RETAIL2,DR_1002_10CNT,OFFPEAK_EVENING,10
|
||||
RP_RETAIL2,DR_1002_10CNT,OFFPEAK_WEEKEND,10
|
||||
RP_RETAIL2,DR_1003_10CNT,OFFPEAK_MORNING,10
|
||||
RP_RETAIL2,DR_1003_10CNT,OFFPEAK_EVENING,10
|
||||
RP_RETAIL2,DR_1003_10CNT,OFFPEAK_WEEKEND,10
|
||||
RP_RETAIL2,DR_FS_10CNT,OFFPEAK_MORNING,10
|
||||
RP_RETAIL2,DR_FS_10CNT,OFFPEAK_EVENING,10
|
||||
RP_RETAIL2,DR_FS_10CNT,OFFPEAK_WEEKEND,10
|
||||
RP_SPECIAL_1002,DR_SPECIAL_1002,ALWAYS,10
|
||||
|
@@ -1,4 +0,0 @@
|
||||
#Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject
|
||||
*out,cgrates.org,call,*any,2014-01-14T00:00:00Z,RP_RETAIL1,
|
||||
*out,cgrates.org,call,1001;1006,2014-01-14T00:00:00Z,RP_RETAIL2,
|
||||
*out,cgrates.org,call,SPECIAL_1002,2014-01-14T00:00:00Z,RP_SPECIAL_1002,
|
||||
|
@@ -1,2 +0,0 @@
|
||||
#Id,Account,Strategy,RatingSubject
|
||||
SHARED_A,*any,*highest,
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#Tag,Years,Months,MonthDays,WeekDays,Time
|
||||
ALWAYS,*any,*any,*any,*any,00:00:00
|
||||
ASAP,*any,*any,*any,*any,*asap
|
||||
PEAK,*any,*any,*any,1;2;3;4;5,08:00:00
|
||||
OFFPEAK_MORNING,*any,*any,*any,1,00:00:00
|
||||
OFFPEAK_EVENING,*any,*any,*any,1;2;3;4;5,19:00:00
|
||||
OFFPEAK_WEEKEND,*any,*any,*any,6;7,00:00:00
|
||||
|
@@ -110,18 +110,21 @@ func (self *SQLStorage) GetTPTableIds(tpid, table string, distinct utils.TPDisti
|
||||
qry += fmt.Sprintf(" AND %s='%s'", key, value)
|
||||
}
|
||||
}
|
||||
if pagination.SearchTerm != "" {
|
||||
qry += fmt.Sprintf(" AND (%s LIKE '%%%s%%'", distinct[0], pagination.SearchTerm)
|
||||
for _, d := range distinct[1:] {
|
||||
qry += fmt.Sprintf(" OR %s LIKE '%%%s%%'", d, pagination.SearchTerm)
|
||||
}
|
||||
qry += fmt.Sprintf(")")
|
||||
}
|
||||
if pagination != nil {
|
||||
limLow, limHigh := pagination.GetLimits()
|
||||
qry += fmt.Sprintf(" LIMIT %d,%d", limLow, limHigh)
|
||||
if len(pagination.SearchTerm) != 0 {
|
||||
qry += fmt.Sprintf(" AND (%s LIKE '%%%s%%'", distinct[0], pagination.SearchTerm)
|
||||
for _, d := range distinct[1:] {
|
||||
qry += fmt.Sprintf(" OR %s LIKE '%%%s%%'", d, pagination.SearchTerm)
|
||||
}
|
||||
qry += fmt.Sprintf(")")
|
||||
}
|
||||
if pagination.Limit != nil { // Keep Postgres compatibility by adding offset only when limit defined
|
||||
qry += fmt.Sprintf(" LIMIT %d", *pagination.Limit)
|
||||
if pagination.Offset != nil {
|
||||
qry += fmt.Sprintf(" OFFSET %d", *pagination.Offset)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rows, err := self.Db.Query(qry)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -958,12 +961,13 @@ func (self *SQLStorage) GetStoredCdrs(qryFltr *utils.CdrsFilter) ([]*utils.Store
|
||||
if qryFltr.IgnoreDerived {
|
||||
q = q.Where(utils.TBL_RATED_CDRS+".runid = ?", utils.DEFAULT_RUNID)
|
||||
}
|
||||
if qryFltr.PaginatorOffset != 0 {
|
||||
q = q.Offset(qryFltr.PaginatorOffset)
|
||||
if qryFltr.Paginator.Limit != nil {
|
||||
q = q.Limit(*qryFltr.Paginator.Limit)
|
||||
}
|
||||
if qryFltr.PaginatorLimit != 0 {
|
||||
q = q.Limit(qryFltr.PaginatorLimit)
|
||||
if qryFltr.Paginator.Offset != nil {
|
||||
q = q.Offset(*qryFltr.Paginator.Offset)
|
||||
}
|
||||
|
||||
/*
|
||||
// ToDo: Fix as soon as issue on Gorm analyzed: https://github.com/jinzhu/gorm/issues/354
|
||||
if qryFltr.Count {
|
||||
@@ -1106,9 +1110,12 @@ func (self *SQLStorage) GetTpDestinationRates(tpid, tag string, pagination *util
|
||||
q = q.Where("tag = ?", tag)
|
||||
}
|
||||
if pagination != nil {
|
||||
limLow, limHigh := pagination.GetLimits()
|
||||
q = q.Offset(limLow)
|
||||
q = q.Limit(limHigh)
|
||||
if pagination.Limit != nil {
|
||||
q = q.Limit(*pagination.Limit)
|
||||
}
|
||||
if pagination.Offset != nil {
|
||||
q = q.Offset(*pagination.Offset)
|
||||
}
|
||||
}
|
||||
if err := q.Find(&tpDestinationRates).Error; err != nil {
|
||||
return nil, err
|
||||
@@ -1166,11 +1173,13 @@ func (self *SQLStorage) GetTpRatingPlans(tpid, tag string, pagination *utils.Pag
|
||||
if err := q.Find(&tpRatingPlans).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if pagination != nil {
|
||||
limLow, limHigh := pagination.GetLimits()
|
||||
q = q.Offset(limLow)
|
||||
q = q.Limit(limHigh)
|
||||
if pagination.Limit != nil {
|
||||
q = q.Limit(*pagination.Limit)
|
||||
}
|
||||
if pagination.Offset != nil {
|
||||
q = q.Offset(*pagination.Offset)
|
||||
}
|
||||
}
|
||||
|
||||
for _, tpRp := range tpRatingPlans {
|
||||
|
||||
@@ -20,7 +20,6 @@ package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -36,17 +35,18 @@ func (tpdi TPDistinctIds) String() string {
|
||||
|
||||
// To paginate stuff from stordb (e.g. ids)
|
||||
type Paginator struct {
|
||||
Page int
|
||||
ItemsPerPage int
|
||||
SearchTerm string
|
||||
Limit *int
|
||||
Offset *int
|
||||
SearchTerm string
|
||||
}
|
||||
|
||||
func (pag *Paginator) GetLimits() (low, high int) {
|
||||
/*func (pag *Paginator) GetLimits() (low, high int) {
|
||||
if pag.ItemsPerPage == 0 {
|
||||
return 0, math.MaxInt32
|
||||
}
|
||||
return pag.Page * pag.ItemsPerPage, pag.ItemsPerPage
|
||||
}
|
||||
*/
|
||||
|
||||
// Used on exports (eg: TPExport)
|
||||
type ExportedData interface {
|
||||
@@ -929,9 +929,8 @@ type CdrsFilter struct {
|
||||
CostStart *float64 // Start of the cost interval (>=)
|
||||
CostEnd *float64 // End of the usage interval (<)
|
||||
IgnoreDerived bool // Do not consider derived CDRs but original one
|
||||
PaginatorOffset int // Start retrieving from this offset
|
||||
PaginatorLimit int // Limit the number of items retrieved
|
||||
Count bool // If true count the items instead of returning data
|
||||
Paginator
|
||||
}
|
||||
|
||||
// Used in Rpc calls, slightly different than CdrsFilter by using string instead of Time filters
|
||||
@@ -1027,8 +1026,7 @@ func (self *RpcCdrsFilter) AsCdrsFilter() (*CdrsFilter, error) {
|
||||
CostStart: self.CostStart,
|
||||
CostEnd: self.CostEnd,
|
||||
IgnoreDerived: self.IgnoreDerived,
|
||||
PaginatorOffset: self.Paginator.Page,
|
||||
PaginatorLimit: self.Paginator.ItemsPerPage,
|
||||
Paginator: self.Paginator,
|
||||
}
|
||||
if len(self.SetupTimeStart) != 0 {
|
||||
if sTimeStart, err := ParseTimeDetectLayout(self.SetupTimeStart); err != nil {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package utils
|
||||
|
||||
const (
|
||||
VERSION = "0.9.1rc5"
|
||||
VERSION = "0.9.1rc6"
|
||||
POSTGRES = "postgres"
|
||||
MYSQL = "mysql"
|
||||
MONGO = "mongo"
|
||||
@@ -168,6 +168,7 @@ const (
|
||||
HTTP_POST = "http_post"
|
||||
NANO_MULTIPLIER = 1000000000
|
||||
CGR_AUTHORIZE = "CGR_AUTHORIZE"
|
||||
CONFIG_DIR = "/etc/cgrates"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user