updated commands parameters, corrected cache and docs

This commit is contained in:
Radu Ioan Fericean
2012-08-20 14:27:53 +03:00
parent 3661d60805
commit 9ebaf42fcd
13 changed files with 252 additions and 243 deletions

View File

@@ -22,23 +22,24 @@ import (
"flag"
"fmt"
"github.com/cgrates/cgrates/timespans"
"log"
"net/rpc"
"net/rpc/jsonrpc"
"os"
"time"
)
var (
cmd = flag.String("cmd", "", "server address host:port")
server = flag.String("server", "127.0.0.1:2001", "server address host:port")
tor = flag.String("tor", "0", "Type of record")
direction = flag.String("direction", "OUT", "Call direction")
tenant = flag.String("tenant", "vdf", "Tenant identificator")
subject = flag.String("subject", "rif", "The client who made the call")
account = flag.String("account", "rif", "The the user balance to be used")
dest = flag.String("dest", "041", "Call destination")
start = flag.String("start", "2012-02-09T00:00:00Z", "Time start")
end = flag.String("end", "2012-02-09T00:10:00Z", "Time end")
amount = flag.Float64("amount", 100, "Amount for different operations")
tenant = flag.String("tenant", "", "Tenant identificator")
subject = flag.String("subject", "", "The client who made the call")
account = flag.String("account", "", "The the user balance to be used")
dest = flag.String("dest", "", "Call destination")
start = flag.String("start", "", "Time start (format: 2012-02-09T00:00:00Z)")
end = flag.String("end", "", "Time end (format: 2012-02-09T00:00:00Z)")
amount = flag.Float64("amount", 0, "Amount for different operations")
json = flag.Bool("json", false, "Use JSON for RPC encoding.")
)
@@ -52,20 +53,20 @@ func main() {
client, err = rpc.Dial("tcp", *server)
}
if err != nil {
timespans.Logger.Crit(fmt.Sprintf("Could not connect to server " + *server))
os.Exit(1)
flag.PrintDefaults()
log.Fatal("Could not connect to server " + *server)
}
defer client.Close()
timestart, err := time.Parse(time.RFC3339, *start)
if err != nil {
timespans.Logger.Crit(fmt.Sprintf("Time start format is invalid: ", err))
os.Exit(2)
flag.PrintDefaults()
log.Fatal("Time start format is invalid: ", err)
}
timeend, err := time.Parse(time.RFC3339, *end)
if err != nil {
timespans.Logger.Crit(fmt.Sprintf("Time end format is invalid: ", err))
os.Exit(3)
flag.PrintDefaults()
log.Fatal("Time end format is invalid: ", err)
}
cd := &timespans.CallDescriptor{
@@ -80,7 +81,7 @@ func main() {
Amount: *amount,
}
switch flag.Arg(0) {
switch *cmd {
case "getcost":
result := timespans.CallCost{}
if err = client.Call("Responder.GetCost", cd, &result); err == nil {
@@ -134,6 +135,8 @@ func main() {
default:
fmt.Println("List of commands:")
fmt.Println("\tgetcost")
fmt.Println("\tdebit")
fmt.Println("\tmaxdebit")
fmt.Println("\tgetmaxsessiontime")
fmt.Println("\tdebitbalance")
fmt.Println("\tdebitsms")
@@ -144,7 +147,7 @@ func main() {
flag.PrintDefaults()
}
if err != nil {
timespans.Logger.Crit(err.Error())
os.Exit(1)
log.Print(cd.GetKey())
log.Fatal(err)
}
}

View File

@@ -20,6 +20,7 @@ package main
import (
"code.google.com/p/goconf/conf"
"errors"
"flag"
"fmt"
"github.com/cgrates/cgrates/balancer"
@@ -49,19 +50,19 @@ const (
)
var (
config = flag.String("config", "rater_standalone.config", "Configuration file location.")
data_db_type = REDIS
data_db_host = "localhost" // The host to connect to. Values that start with / are for UNIX domain sockets.
data_db_port = "" // The port to bind to.
data_db_name = "10" // The name of the database to connect to.
data_db_user = "" // The user to sign in as.
data_db_password = "" // The user's password.
logging_db_type = MONGO
logging_db_host = "localhost" // The host to connect to. Values that start with / are for UNIX domain sockets.
logging_db_port = "" // The port to bind to.
logging_db_name = "cgrates" // The name of the database to connect to.
logging_db_user = "" // The user to sign in as.
logging_db_password = "" // The user's password.
config = flag.String("config", "rater_standalone.config", "Configuration file location.")
data_db_type = REDIS
data_db_host = "localhost" // The host to connect to. Values that start with / are for UNIX domain sockets.
data_db_port = "" // The port to bind to.
data_db_name = "10" // The name of the database to connect to.
data_db_user = "" // The user to sign in as.
data_db_pass = "" // The user's password.
log_db_type = MONGO
log_db_host = "localhost" // The host to connect to. Values that start with / are for UNIX domain sockets.
log_db_port = "" // The port to bind to.
log_db_name = "cgrates" // The name of the database to connect to.
log_db_user = "" // The user to sign in as.
log_db_pass = "" // The user's password.
rater_enabled = false // start standalone server (no balancer)
rater_balancer = DISABLED // balancer address host:port
@@ -105,13 +106,13 @@ func readConfig(c *conf.ConfigFile) {
data_db_port, _ = c.GetString("global", "datadb_port")
data_db_name, _ = c.GetString("global", "datadb_name")
data_db_user, _ = c.GetString("global", "datadb_user")
data_db_password, _ = c.GetString("global", "datadb_passwd")
logging_db_type, _ = c.GetString("global", "logdb_type")
logging_db_host, _ = c.GetString("global", "logdb_host")
logging_db_port, _ = c.GetString("global", "logdb_port")
logging_db_name, _ = c.GetString("global", "logdb_name")
logging_db_user, _ = c.GetString("global", "logdb_user")
logging_db_password, _ = c.GetString("global", "logdb_passwd")
data_db_pass, _ = c.GetString("global", "datadb_passwd")
log_db_type, _ = c.GetString("global", "logdb_type")
log_db_host, _ = c.GetString("global", "logdb_host")
log_db_port, _ = c.GetString("global", "logdb_port")
log_db_name, _ = c.GetString("global", "logdb_name")
log_db_user, _ = c.GetString("global", "logdb_user")
log_db_pass, _ = c.GetString("global", "logdb_passwd")
rater_enabled, _ = c.GetBool("rater", "enabled")
rater_balancer, _ = c.GetString("rater", "balancer")
@@ -285,6 +286,36 @@ func checkConfigSanity() {
}
}
func configureDatabase(db_type, host, port, name, user, pass string) (getter timespans.StorageGetter, err error) {
switch db_type {
case REDIS:
db_nb, err := strconv.Atoi(name)
if err != nil {
timespans.Logger.Crit("Redis db name must be an integer!")
exitChan <- true
}
if port != "" {
host += ":" + port
}
getter, err = timespans.NewRedisStorage(host, db_nb, pass)
case MONGO:
getter, err = timespans.NewMongoStorage(host, port, name, user, pass)
case POSTGRES:
getter, err = timespans.NewPostgresStorage(host, port, name, user, pass)
default:
err = errors.New("unknown db")
timespans.Logger.Crit("Unknown db type, exiting!")
exitChan <- true
}
if err != nil {
timespans.Logger.Crit(fmt.Sprintf("Could not connect to db: %v, exiting!", err))
exitChan <- true
}
return
}
func main() {
flag.Parse()
runtime.GOMAXPROCS(runtime.NumCPU())
@@ -297,33 +328,25 @@ func main() {
// some consitency checks
go checkConfigSanity()
var getter timespans.StorageGetter
switch data_db_type {
case REDIS:
db_nb, err := strconv.Atoi(data_db_name)
if err != nil {
timespans.Logger.Crit("Redis db name must be an integer!")
exitChan <- true
}
if data_db_port != "" {
data_db_host += ":" + data_db_port
}
getter, err = timespans.NewRedisStorage(data_db_host, db_nb, data_db_password)
case MONGO:
getter, err = timespans.NewMongoStorage(data_db_host, data_db_port, data_db_name, data_db_user, data_db_password)
case POSTGRES:
getter, err = timespans.NewPostgresStorage(data_db_host, data_db_port, data_db_name, data_db_user, data_db_password)
default:
timespans.Logger.Crit("Unknown data db type, exiting!")
exitChan <- true
}
var getter, loggerDb timespans.StorageGetter
go func() {
getter, err = configureDatabase(data_db_type, data_db_host, data_db_port, data_db_name, data_db_user, data_db_pass)
if err != nil {
timespans.Logger.Crit("Could not connect to data db, exiting!")
exitChan <- true
}
defer getter.Close()
timespans.SetStorageGetter(getter)
if err == nil {
defer getter.Close()
timespans.SetStorageGetter(getter)
}
if log_db_type == SAME {
loggerDb = getter
} else {
loggerDb, err = configureDatabase(log_db_type, log_db_host, log_db_port, log_db_name, log_db_user, log_db_pass)
}
if err == nil {
defer loggerDb.Close()
timespans.SetStorageLogger(loggerDb)
}
}()
if sm_debit_period > 0 {
if dp, err := time.ParseDuration(fmt.Sprintf("%vs", sm_debit_period)); err == nil {
@@ -331,26 +354,6 @@ func main() {
}
}
var loggerDb timespans.StorageGetter
switch logging_db_type {
case POSTGRES:
loggerDb, err = timespans.NewPostgresStorage(logging_db_host, logging_db_port, logging_db_name, logging_db_user, logging_db_password)
case MONGO:
loggerDb, err = timespans.NewMongoStorage(logging_db_host, logging_db_port, logging_db_name, logging_db_user, logging_db_password)
case SAME:
loggerDb = getter
default:
timespans.Logger.Crit("Unknown logger db type, exiting!")
exitChan <- true
}
if err != nil {
timespans.Logger.Err(fmt.Sprintf("Could not connect to logger database: %v", err))
exitChan <- true
}
timespans.SetStorageLogger(loggerDb)
if rater_enabled && rater_balancer != DISABLED && !balancer_enabled {
go registerToBalancer()
go stopRaterSingnalHandler()

View File

@@ -92,13 +92,13 @@ func TestConfig(t *testing.T) {
data_db_port != "test" ||
data_db_name != "test" ||
data_db_user != "test" ||
data_db_password != "test" ||
logging_db_type != "test" ||
logging_db_host != "test" ||
logging_db_port != "test" ||
logging_db_name != "test" ||
logging_db_user != "test" ||
logging_db_password != "test" ||
data_db_pass != "test" ||
log_db_type != "test" ||
log_db_host != "test" ||
log_db_port != "test" ||
log_db_name != "test" ||
log_db_user != "test" ||
log_db_pass != "test" ||
rater_enabled != true ||
rater_balancer != "test" ||
@@ -134,13 +134,13 @@ func TestConfig(t *testing.T) {
t.Log(data_db_port)
t.Log(data_db_name)
t.Log(data_db_user)
t.Log(data_db_password)
t.Log(logging_db_type)
t.Log(logging_db_host)
t.Log(logging_db_port)
t.Log(logging_db_name)
t.Log(logging_db_user)
t.Log(logging_db_password)
t.Log(data_db_pass)
t.Log(log_db_type)
t.Log(log_db_host)
t.Log(log_db_port)
t.Log(log_db_name)
t.Log(log_db_user)
t.Log(log_db_pass)
t.Log(rater_enabled)
t.Log(rater_balancer)
t.Log(rater_listen)

View File

@@ -15,15 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>
[global]
logdb_type = redis #
logdb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_name = 10 # The name of the database to connect to.
logdb_type = postgres #
datadb_type = redis #
datadb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
datadb_name = 10 # The name of the database to connect to.
logdb_type = mongo
logdb_host = localhost # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_port = 5432 # The port to bind to.
logdb_name = gosqltest # The name of the database to connect to.
logdb_user = rif # The user to sign in as.
logdb_passwd = testus # The user's password.root
logdb_name = cgrates # The name of the database to connect to.
[balancer]
enabled = true # Start balancer server
@@ -38,4 +35,4 @@ rpc_encoding = gob # use JSON for RPC encoding
[stats_server]
enabled = true
listen = 127.0.0.1:8000 # Web server address (for stat reports)
listen = 127.0.0.1:8000 # Web server address (for stat reports)

View File

@@ -15,15 +15,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>
[global]
logdb_type = redis #
logdb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_name = 10 # The name of the database to connect to.
logdb_type = postgres #
datadb_type = redis #
datadb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
datadb_name = 10 # The name of the database to connect to.
logdb_type = mongo
logdb_host = localhost # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_port = 5432 # The port to bind to.
logdb_name = gosqltest # The name of the database to connect to.
logdb_user = rif # The user to sign in as.
logdb_passwd = testus # The user's password.root
logdb_name = cgrates # The name of the database to connect to.
[balancer]
enabled = true # Start balancer server
@@ -36,4 +34,4 @@ enabled = false
[stats_server]
enabled = true
listen = 127.0.0.1:8000 # Web server address (for stat reports)
listen = 127.0.0.1:8000 # Web server address (for stat reports)

View File

@@ -15,15 +15,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>
[global]
logdb_type = redis #
logdb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_name = 10 # The name of the database to connect to.
logdb_type = postgres #
datadb_type = redis #
datadb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
datadb_name = 10 # The name of the database to connect to.
logdb_type = mongo
logdb_host = localhost # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_port = 5432 # The port to bind to.
logdb_name = gosqltest # The name of the database to connect to.
logdb_user = rif # The user to sign in as.
logdb_passwd = testus # The user's password.root
logdb_name = cgrates # The name of the database to connect to.
[balancer]
enabled = false # Start balancer server

View File

@@ -15,15 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>
[global]
logdb_type = redis #
logdb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_name = 10 # The name of the database to connect to.
logdb_type = postgres #
datadb_type = redis
datadb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
datadb_name = 10 # The name of the database to connect to.
logdb_type = mongo
logdb_host = localhost # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_port = 5432 # The port to bind to.
logdb_name = gosqltest # The name of the database to connect to.
logdb_user = rif # The user to sign in as.
logdb_passwd = testus # The user's password.root
logdb_name = cgrates # The name of the database to connect to.
[rater]
enabled = true

View File

@@ -15,15 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>
[global]
logdb_type = redis #
logdb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_name = 10 # The name of the database to connect to.
logdb_type = postgres #
datadb_type = redis
datadb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
datadb_name = 10 # The name of the database to connect to.
logdb_type = mongo
logdb_host = localhost # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_port = 5432 # The port to bind to.
logdb_name = gosqltest # The name of the database to connect to.
logdb_user = rif # The user to sign in as.
logdb_passwd = testus # The user's password.root
logdb_name = cgrates # The name of the database to connect to.
[rater]
enabled = true

View File

@@ -15,15 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>
[global]
logdb_type = redis #
logdb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_name = 10 # The name of the database to connect to.
logdb_type = postgres #
logdb_host = localhost # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_port = 5432 # The port to bind to.
logdb_name = gosqltest # The name of the database to connect to.
logdb_user = rif # The user to sign in as.
logdb_passwd = testus # The user's password.root
datadb_type = redis
datadb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
datadb_name = 10 # The name of the database to connect to.
logdb_type = same
[rater]
enabled = true
@@ -33,4 +28,4 @@ rpc_encoding = gob # use JSON for RPC encoding
[stats_server]
enabled = true
listen = 127.0.0.1:8000 # Web server address (for stat reports)
listen = 127.0.0.1:8000 # Web server address (for stat reports)

View File

@@ -15,9 +15,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>
[global]
logdb_type = redis #
logdb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_name = 10 # The name of the database to connect to.
datadb_type = redis #
datadb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
datadb_name = 10 # The name of the database to connect to.
logdb_type = mongo #
logdb_host = localhost # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_name = cgrates # The name of the database to connect to.

View File

@@ -15,10 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>
[global]
logdb_type = redis #
logdb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_name = 10 # The name of the database to connect to.
logdb_type = mongo #
datadb_type = redis
datadb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
datadb_name = 10 # The name of the database to connect to.
logdb_type = mongo
logdb_host = localhost # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_name = cgrates # The name of the database to connect to.

View File

@@ -31,43 +31,119 @@ This will install the sources and compile all available tools
Running
-------
The CGRateS suite is formed by seven tools described bellow.
The CGRateS suite is formed by three tools described bellow. We'll start with the most important one, cgr-rater which is configured with an ini style configuration file.
cgr-balancer
~~~~~~~~~~~~
The cgr-balancer will open a JSON RPC server and an HTTP server ready for taking external requests. It will also open a rater server on witch the raters will register themselves when they start.
::
rif@grace:~$ cgr-balancer --help
Usage of cgr-balancer:
-freeswitch=false: connect to freeswitch server
-freeswitchpass="ClueCon": freeswitch address host:port
-freeswitchsrv="localhost:8021": freeswitch address host:port
-httpapiaddr="127.0.0.1:8000": Http API server address (localhost:2002)
-json=false: use JSON for RPC encoding
-jsonrpcaddr="127.0.0.1:2001": Json RPC server address (localhost:2001)
-rateraddr="127.0.0.1:2000": Rater server address (localhost:2000)
:Example: cgr-balancer -freeswitch=true -httpapiaddr=127.0.0.1:6060 -json=true
cgr-rater
~~~~~~~~~
The cgr-rater can be provided with the balancer server address and can be configured to listen to a specific interface and port. It is an auxiliary tool only and is meant to be used for housekeeping duties (better alternative to curl inspection).
::
rif@grace:~$ cgr-rater --help
Usage of cgr-rater:
-balancer="127.0.0.1:2000": balancer address host:port
-freeswitch=false: connect to freeswitch server
-freeswitchpass="ClueCon": freeswitch address host:port
-freeswitchsrv="localhost:8021": freeswitch address host:port
-json=false: use JSON for RPC encoding
-listen="127.0.0.1:1234": listening address host:port
-redisdb=10: redis database number
-redissrv="127.0.0.1:6379": redis address host:port
-standalone=false: start standalone server (no balancer)
rif@grace:~$ cgr-rater -help
Usage of cgr-rater:
-config="rater_standalone.config": Configuration file location.
:Example: cgr-rater -config=full.config
Bellow there is a full configuration file
::
[global]
[global]
datadb_type = redis #
datadb_host = 127.0.0.1:6379 # The host to connect to. Values that start with / are for UNIX domain sockets.
datadb_name = 10 # The name of the database to connect to.
logdb_type = postgres #
logdb_host = localhost # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_port = 5432 # The port to bind to.
logdb_name = gosqltest # The name of the database to connect to.
logdb_user = rif # The user to sign in as.
logdb_passwd = test # The user's password.root
[balancer]
enabled = false # Start balancer server
listen = 127.0.0.1:2001 # Balancer listen interface
rpc_encoding = gob # use JSON for RPC encoding
[rater]
enabled = true
listen = 127.0.0.1:2001 # listening address host:port, internal for internal communication only
balancer = disabled # if defined it will register to balancer as worker
rpc_encoding = gob # use JSON for RPC encoding
[mediator]
enabled = true
cdr_file = Master.csv # Freeswitch Master CSV CDR file.
result_file = out.csv # Generated file containing CDR and price info.
rater = internal #address where to access rater. Can be internal, direct rater address or the address of a balancer
rpc_encoding = gob # use JSON for RPC encoding
skipdb = true
[scheduler]
enabled = true
[session_manager]
enabled = true
rater = 127.0.0.1:2000 #address where to access rater. Can be internal, direct rater address or the address of a balancer
freeswitch_server = localhost:8021 # freeswitch address host:port
freeswitch_pass = ClueCon # freesw/home/rif/Documents/prog/go/src/github.com/cgrates/cgrates/confitch address host:port
rpc_encoding = gob # use JSON for RPC encoding
[stats_server]
enabled = true
listen = 127.0.0.1:8000 # Web server address (for stat reports)
media_path = /home/rif/Documents/prog/go/src/github.com/cgrates/cgrates/data
The balancer will open a JSON RPC server and an HTTP server ready for taking external requests. It will also open a rater server on witch the raters will register themselves when they start.
Session manager connects and monitors the freeswitch server issuing API request to other CGRateS components. It can run in standalone mode for minimal system configuration. It logs the calls information to a postgres database in order to be used by the mediator tool.
The scheduler is loading the timed actions form database and executes them as appropriate, It will execute all run once actions as they are loaded. It will reload all the action timings from the database when it received system HUP signal (pkill -1 cgr-rater).
The mediator parses the call logs written in a postgres database by the session manager and writes the call costs to a freeswitch CDR file.
The structure of the table (as an SQL command) is the following::
::
CREATE TABLE callcosts (
uuid varchar(80) primary key,
direction varchar(32),
tenant varchar(32),
tor varchar(32),
subject varchar(32),
account varchar(32),
destination varchar(32),
cost real,
conect_fee real,
timespans text
);
cgr-loader
~~~~~~~~~~
This tool is used for importing the data from CSV files into the CGRateS database system. The structure of the CSV files is described in the :ref:`data-importing` chapter.
::
rif@grace:~$ cgr-loader -help
Usage of cgr-loader:
-dbhost="localhost": The database host to connect to.
-dbname="10": he name/number of the database to connect to.
-dbpass="": The database user's password.
-dbport="6379": The database port to bind to.
-dbtype="redis": The type of the database (redis|mongo|postgres)
-dbuser="": The database user to sign in as.
-flush=false: Flush the database before importing
-path=".": The path containing the data files
:Example: cgr-loader -flush
:Example: cgr-rater -balancer=127.0.0.1:2000
cgr-console
~~~~~~~~~~~
@@ -94,60 +170,5 @@ The cgr-console is a command line tool used to access the balancer (or the rater
-start="2012-02-09T00:00:00Z": Time start
-end="2012-02-09T00:10:00Z": Time end
:Example: cgr-console getcost -subject=rif -dest=0723045326 -start=2012-07-13T15:38:00Z -end=2012-07-13T15:39:00Z
cgr-loader
~~~~~~~~~~
This tool is used for importing the data from CSV files into the CGRateS database system. The structure of the CSV files is described in the :ref:`data-importing` chapter.
::
rif@grace:~$ cgr-loader --help
Usage of cgr-loader:
-accountactions="": Account actions file
-actions="": Actions file
-actiontimings="": Actions timings file
-actiontriggers="": Actions triggers file
-destinations="": Destinations file
-flush=false: Flush the database before importing
-month="": Months file
-monthdays="": Month days file
-pass="": redis database password
-rates="": Rates file
-ratetimings="": Rates timings file
-ratingprofiles="": Rating profiles file
-redisdb=10: redis database number (10)
-redissrv="127.0.0.1:6379": redis server address (tcp:127.0.0.1:6379)
-separator=",": Default field separator
-timings="": Timings file
-weekdays="": Week days file
:Example: cgr-loader -destinations=Destinations.csv
Session manager connects and monitors the freeswitch server issuing API request to other CGRateS components. It can run in standalone mode for minimal system configuration. It logs the calls information to a postgres database in order to be used by the mediator tool.
The scheduler is loading the timed actions form database and executes them as appropriate, It will execute all run once actions as they are loaded. It will reload all the action timings from the database when it received system HUP signal (pkill -1 cgr-schedule).
The mediator parses the call logs written in a postgres database by the session manager and writes the call costs to a freeswitch CDR file.
The structure of the table (as an SQL command) is the following::
CREATE TABLE callcosts (
uuid varchar(80) primary key,
direction varchar(32),
tenant varchar(32),
tor varchar(32),
subject varchar(32),
account varchar(32),
destination varchar(32),
cost real,
conect_fee real,
timespans text
);
::
:Example: cgr-console -cmd=getcost -subject=rif -tenant=vdf -dest=419 -start=2012-02-09T00:00:00Z -end=2012-02-09T00:01:00Z

View File

@@ -129,7 +129,7 @@ func SetDebitPeriod(d time.Duration) {
Restores the activation periods for the specified prefix from storage.
*/
func (cd *CallDescriptor) LoadActivationPeriods() (destPrefix string, err error) {
if val, err := cache.GetXCached(cd.GetKey()); err == nil {
if val, err := cache.GetXCached(cd.GetKey() + cd.Destination); err == nil {
xaps := val.(xCachedActivationPeriods)
cd.ActivationPeriods = xaps.aps
return xaps.destPrefix, nil
@@ -143,7 +143,7 @@ func (cd *CallDescriptor) LoadActivationPeriods() (destPrefix string, err error)
//load the activation preriods
if err == nil && len(values) > 0 {
xaps := xCachedActivationPeriods{destPrefix, values, new(cache.XEntry)}
xaps.XCache(cd.GetKey(), debitPeriod+5*time.Second, xaps)
xaps.XCache(cd.GetKey()+cd.Destination, debitPeriod+5*time.Second, xaps)
cd.ActivationPeriods = values
}
return