Added Tenant field to TPstats

This commit is contained in:
edwardro22
2017-09-12 08:45:53 +00:00
parent df31455316
commit 40cd82dc26
15 changed files with 125 additions and 48 deletions

View File

@@ -6,19 +6,20 @@
# ^ the script will "move" the collections if source and target server are the same
# but will "copy" (dump/restore) if source and target servers are different
from_host = '127.0.0.1'
from_port = '27017'
from_db = '11'
from_auth_db = 'cgrates' # Auth db on source server
from_user = 'cgrates'
from_pass = ''
to_host = '127.0.0.1'
to_port = '27017'
to_db = '10'
to_auth_db = "cgrates" # Auth db on target server
to_user = 'cgrates'
to_pass = ''
from_host =os.environ["from_host"]
from_port =os.environ["from_port"]
from_auth_db =os.environ["from_auth_db"]
from_user =os.environ["from_user"]
from_pass =os.environ["from_pass"]
to_host =os.environ["to_host"]
to_port =os.environ["to_port"]
to_auth_db =os.environ["to_auth_db"]
to_user =os.environ["to_user"]
to_pass =os.environ["to_pass"]
ignore_empty_cols = True
# Do not migrate collections with 0 document count.

View File

@@ -23,6 +23,19 @@ timeout = 2000
import time
import redis
import os
from_host =os.environ["from_host"]
from_port =os.environ["from_port"]
from_db =os.environ["from_db"]
from_pass =os.environ["from_pass"]
to_host =os.environ["to_host"]
to_port =os.environ["to_port"]
to_db =os.environ["to_db"]
to_pass =os.environ["to_pass"]
from_redis = redis.Redis(host = from_host, port = from_port, password=from_pass, db = from_db)
to_redis = redis.Redis(host = to_host, port = to_port, db = to_db)

View File

@@ -1,28 +1,80 @@
#! /usr/bin/env sh
if test $# -lt 2; then
echo ""
echo "setup_cgr_db.sh <datadb_name> <stordb_name> <User> <host>"
echo ""
exit 0
#settings
echo ""
echo "rc7_to_rc8.sh"
echo ""
$datadb="redis"
if [$datadb="redis"];then
#Redis Config
export from_host = '192.168.100.40'
export from_port = 6379
export from_db = 11
export from_pass = ''
export to_host = '192.168.100.40'
export to_port = 6379
export to_db = 10
export to_pass = '' # Not used
else if [$datadb="mongo"];then
#Mongo Config
export from_host = '127.0.0.1'
export from_port = '27017'
export from_db = '11'
export from_auth_db = 'cgrates' # Auth db on source server
export from_user = 'cgrates'
export from_pass = ''
export to_host = '127.0.0.1'
export to_port = '27017'
export to_db = '10'
export to_auth_db = "cgrates" # Auth db on target server
export to_user = 'cgrates'
export to_pass = ''
fi
user=$3
if [ -z "$3" ]; then
user="cgrates"
if [$stordb="redis"];then
#Redis Config
export from_host = '192.168.100.40'
export from_port = 6379
export from_db = 11
export from_pass = ''
export to_host = '192.168.100.40'
export to_port = 6379
export to_db = 10
export to_pass = '' # Not used
else if [$stordb="mysql"];then
#Mongo Config
export from_host = '127.0.0.1'
export from_port = '27017'
export from_db = '11'
export from_auth_db = 'cgrates' # Auth db on source server
export from_user = 'cgrates'
export from_pass = ''
export to_host = '127.0.0.1'
export to_port = '27017'
export to_db = '10'
export to_auth_db = "cgrates" # Auth db on target server
export to_user = 'cgrates'
export to_pass = ''
fi
host=$4
if [ -z "$4" ]; then
host="localhost"
fi
export PGPASSWORD="CGRateS.org"
DIR="$(dirname "$(readlink -f "$0")")"
case $1 in
case $datadb in
"redis")
./dbsmerge_redis.py
;;
@@ -31,20 +83,18 @@ case $1 in
;;
esac
case $2 in
case $stordb in
"mysql")
mysql -u$user -p$PGPASSWORD -h $host < "$DIR"/mysql_tables_update.sql
up=$?
mysql -u$user -p$PGPASSWORD -h $host -D cgrates < "$DIR"/mysql_cdr_migration.sql
mig=$?
#./usage_mysql.py What's the point of those changes?
;;
"postgres")
psql -U $user -h $host -d cgrates -f "$DIR"/pq_tables_update.sql
up=$?
psql -U $user -h $host -d cgrates -f "$DIR"/pg_cdr_migration.sql
mig=$?
#./usage_postgres.py What's the point of those changes?
;;
esac

View File

@@ -423,6 +423,7 @@ CREATE TABLE tp_resources (
DROP TABLE IF EXISTS tp_stats;
CREATE TABLE tp_stats (
`tenant` varchar(64) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`tpid` varchar(64) NOT NULL,
`tag` varchar(64) NOT NULL,

View File

@@ -419,6 +419,7 @@ CREATE INDEX tp_resources_unique ON tp_resources ("tpid", "tag", "filter_type",
DROP TABLE IF EXISTS tp_stats;
CREATE TABLE tp_stats (
"tenant"varchar(64) NOT NULL,
"id" SERIAL PRIMARY KEY,
"tpid" varchar(64) NOT NULL,
"tag" varchar(64) NOT NULL,

View File

@@ -1,2 +1,2 @@
#Id[0],FilterType[1],FilterFieldName[2],FilterFieldValues[3],ActivationInterval[4],QueueLength[5],TTL[6],Metrics[7],Blocker[8],Stored[9],Weight[10],Thresholds[11]
Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd;*acc,true,true,20,THRESH1;THRESH2
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],QueueLength[6],TTL[7],Metrics[8],Blocker[9],Stored[10],Weight[11],Thresholds[12]
Tester,Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd;*acc,true,true,20,THRESH1;THRESH2
1 #Id[0] #Tenant[0] FilterType[1] Id[1] FilterFieldName[2] FilterType[2] FilterFieldValues[3] FilterFieldName[3] ActivationInterval[4] FilterFieldValues[4] QueueLength[5] ActivationInterval[5] TTL[6] QueueLength[6] Metrics[7] TTL[7] Blocker[8] Metrics[8] Stored[9] Blocker[9] Weight[10] Stored[10] Thresholds[11] Weight[11] Thresholds[12]
2 Stats1 Tester *string Stats1 Account *string 1001;1002 Account 2014-07-29T15:00:00Z 1001;1002 100 2014-07-29T15:00:00Z 1s 100 *asr;*acd;*acc 1s true *asr;*acd;*acc true true 20 true THRESH1;THRESH2 20 THRESH1;THRESH2

View File

@@ -1,2 +1,2 @@
#Id[0],FilterType[1],FilterFieldName[2],FilterFieldValues[3],ActivationInterval[4],QueueLength[5],TTL[6],Metrics[7],Blocker[8],Stored[9],Weight[10],Thresholds[11]
Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd;*acc,true,true,20,THRESH1;THRESH2
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],QueueLength[6],TTL[7],Metrics[8],Blocker[9],Stored[10],Weight[11],Thresholds[12]
Tester,Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd;*acc,true,true,20,THRESH1;THRESH2
1 #Id[0] #Tenant[0] FilterType[1] Id[1] FilterFieldName[2] FilterType[2] FilterFieldValues[3] FilterFieldName[3] ActivationInterval[4] FilterFieldValues[4] QueueLength[5] ActivationInterval[5] TTL[6] QueueLength[6] Metrics[7] TTL[7] Blocker[8] Metrics[8] Stored[9] Blocker[9] Weight[10] Stored[10] Thresholds[11] Weight[11] Thresholds[12]
2 Stats1 Tester *string Stats1 Account *string 1001;1002 Account 2014-07-29T15:00:00Z 1001;1002 100 2014-07-29T15:00:00Z 1s 100 *asr;*acd;*acc 1s true *asr;*acd;*acc true true 20 true THRESH1;THRESH2 20 THRESH1;THRESH2