CGRates new installation

924 views
Skip to first unread message

Nordine Bouti

unread,
Feb 16, 2018, 5:49:28 AM2/16/18
to CGRateS
Hello everyone,

I'm new to CGRates, I followed the tutorial,

I work on a debian 9 VM on azure and i have done this commands :


dpkg -i cgrates_0.9.1~rc8_amd64.deb
aptitude install mongodb
cd /usr/share/cgrates/storage/mongo/
./setup_cgr_db.sh

Successfully added user: {
        "user" : "cgrates",
        "roles" : [
                {
                        "role" : "dbAdmin",
                        "db" : "cgrates"
                }
        ]
}

        +++ CGR-DB successfully set-up! +++
cp /usr/share/cgrates/conf/samples/tutmongo/cgrates.json /etc/cgrates/cgrates.json
cgr-migrator -stordb_passwd="CGRateS.org" -datadb_type="mongo" -datadb_port=27017 -stordb_type="mongo" -stordb_port=27017 -migrate="*set_versions"

But after all this, I'm not able to reach the CGRates api from command line such as : 
telnet localhost 2012

the db in mongo is set, i can see all tabs and when I type 
service cgrates status, i get

cgrates.service - LSB: CGRateS real-time charging system
   Loaded: loaded (/etc/init.d/cgrates; generated; vendor preset: enabled)
   Active: active (exited) since Fri 2018-02-16 10:16:45 UTC; 31min ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/cgrates.service

Feb 16 10:16:45 tmelab-cgr systemd[1]: Starting LSB: CGRateS real-time charging system...
Feb 16 10:16:45 tmelab-cgr cgrates[12045]: CGRateS real-time charging system not yet configured. Edit /etc/default/cgrates first.
Feb 16 10:16:45 tmelab-cgr systemd[1]: Started LSB: CGRateS real-time charging system.

did i miss something or done something wrong during installation ?

Thanks in advance,

nordine Bouti

DanB

unread,
Feb 16, 2018, 7:16:32 AM2/16/18
to cgr...@googlegroups.com
Hi Nordine,

Try enabling CGRateS in /etc/default/cgrates and starting the service
with "service cgrates start". Make sure you have services enabled
within /etc/cgrates/cgrates.json otherwise there will be empty loop
running.

DanB

Nordine Bouti

unread,
Feb 16, 2018, 7:59:44 AM2/16/18
to CGRateS
Hello,

I already did 

service cgrates start
service cgrates restart
edited /etc/default/cgrates and set : 
ENABLE=true
rebooted my vm and still nothing 

My /etc/cgrates/cgrates.json have all values set to true, so i don't see where my mistake come frome.

Ta,

DanB

unread,
Feb 16, 2018, 9:15:08 AM2/16/18
to cgr...@googlegroups.com
Hi Nordine,

Please try the following command and paste here your output:

cgr-engine -logger=*stdout

DanB
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/cgrates/18f8088d-4cb2-413a-ab0f-2e3b55c4a729%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

Nordine Bouti

unread,
Feb 16, 2018, 9:22:29 AM2/16/18
to CGRateS
Hello,

>cgr-engine -logger=*stdout
Migration needed: please backup cgrates data and run : <cgr-migrator>

I don't know why i have this when i type
cgr-migrator -stordb_passwd="CGRateS.org" -datadb_type="mongo" -datadb_port=27017 -stordb_type="mongo" -stordb_port=27017 -migrate="*set_versions"
i don"t see any error.

Ty,

DanB

unread,
Feb 16, 2018, 9:24:04 AM2/16/18
to cgr...@googlegroups.com
Nordine,

Please post your /etc/cgrates/cgrates.json config.

DanB
> msgid/cgrates/9cbb25a6-6828-4dd5-87c9-03034719eca3%40googlegroups.com

Nordine Bouti

unread,
Feb 16, 2018, 9:28:20 AM2/16/18
to CGRateS
Hello,

{
// CGRateS Configuration file


"general": {
"log_level": 7,
"reply_timeout": "30s",
},


"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},


"data_db": {
"db_type": "mongo",
"db_port": 27017,
},


"stor_db": {
"db_type": "mongo",
"db_port": 27017,
},


"cache":{
"destinations": {"limit": 10000, "ttl":"0s", "precache": true},
"reverse_destinations": {"limit": 10000, "ttl":"0s", "precache": true},
"rating_plans": {"limit": 10000, "ttl":"0s","precache": true},
"rating_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"lcr_rules": {"limit": 10000, "ttl":"0s", "precache": true},
"cdr_stats": {"limit": 10000, "ttl":"0s", "precache": true},
"actions": {"limit": 10000, "ttl":"0s", "precache": true},
"action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
"aliases": {"limit": 10000, "ttl":"0s", "precache": true},
"reverse_aliases": {"limit": 10000, "ttl":"0s", "precache": true},
"derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueue_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"thresholds": {"limit": 10000, "ttl":"0s", "precache": true},
"threshold_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"filters": {"limit": 10000, "ttl":"0s", "precache": true},
"supplier_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"attribute_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_filter_indexes" :{"limit": 10000, "ttl":"0s", "precache": true},
"resource_filter_revindexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"stat_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"stat_filter_revindexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"threshold_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"threshold_filter_revindexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"supplier_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"supplier_filter_revindexes" :{"limit": 10000, "ttl":"0s", "precache": true},
"attribute_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"attribute_filter_revindexes" : {"limit": 10000, "ttl":"0s", "precache": true},
},


"rals": {
"enabled": true,
"thresholds_conns": [
{"address": "*internal"}
],
"cdrstats_conns": [
{"address": "*internal"}
],
"pubsubs_conns": [
{"address": "*internal"}
],
"users_conns": [
{"address": "*internal"}
],
"aliases_conns": [
{"address": "*internal"}
],
},


"scheduler": {
"enabled": true,
},


"cdrs": {
"enabled": true,
"cdrstats_conns": [
{"address": "*internal"}
],
},


"cdre": {
"TestTutITExportCDR": {
"content_fields": [
{"tag": "CGRID", "type": "*composed", "value": "CGRID"},
{"tag": "RunID", "type": "*composed", "value": "RunID"},
{"tag":"OriginID", "type": "*composed", "value": "OriginID"},
{"tag":"RequestType", "type": "*composed", "value": "RequestType"},
{"tag":"Tenant", "type": "*composed", "value": "Tenant"},
{"tag":"Category", "type": "*composed", "value": "Category"},
{"tag":"Account", "type": "*composed", "value": "Account"},
{"tag":"Destination", "type": "*composed", "value": "Destination"},
{"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag":"Usage", "type": "*composed", "value": "Usage"},
{"tag":"Cost", "type": "*composed", "value": "Cost", "rounding_decimals": 4},
{"tag":"MatchedDestinationID", "type": "*composed", "value": "~CostDetails:s/\"MatchedDestId\":.*_(\\w{4})/${1}/:s/\"MatchedDestId\":\"INTERNAL\"/ON010/"},
],
},
},


"cdrstats": {
"enabled": true,
},


"pubsubs": {
"enabled": true,
},


"users": {
"enabled": true,
"indexes": ["Uuid"],
},


"resources": {
"enabled": true,
"store_interval": "1s",
"thresholds_conns": [
{"address": "*internal"}
],
},


"stats": {
"enabled": true,
"store_interval": "1s",
"thresholds_conns": [
{"address": "*internal"}
],
},


"thresholds": {
"enabled": true,
"store_interval": "1s",
},


"suppliers": {
"enabled": true,
},


"attributes": { // Attribute service
"enabled": true, // starts Alias service: <true|false>.
},


"aliases": {
"enabled": true,
},


"sessions": {
"enabled": true,
},

DanB

unread,
Feb 16, 2018, 9:44:16 AM2/16/18
to cgr...@googlegroups.com
Nordine,

I think the issue comes from the default config for db_name. We are
pointing towards db_name=10 in case of mongo. When you migrate, you
only migrate cgrates db (set versions).
Try also to add stordb_name and datadb_name everywhere.

DanB

On Fri, 2018-02-16 at 06:28 -0800, Nordine Bouti wrote:
> Hello,
>
> {
> msgid/cgrates/f51b4387-1c1d-4b14-9d08-fb1c32a79cf8%40googlegroups.com

Nordine Bouti

unread,
Feb 16, 2018, 10:14:44 AM2/16/18
to cgr...@googlegroups.com
Hello,

Thank you very much for your time,
edited this lines in /etc/cgrates/cgrates.json:

"data_db": {
        "db_type": "mongo",
        "db_port": 27017,
        "db_name": "cgrates",
},


"stor_db": {
        "db_type": "mongo",
        "db_port": 27017,
        "db_name": "cgrates",
},

I did 

cgr-migrator -stordb_passwd="CGRateS.org" -stordb_name="cgrates" -datadb_name="cgrates" -datadb_type="mongo" -datadb_port=27017 -stordb_type="mongo" -stordb_port=27017 -migrate="*set_versions"
service cgrates force-reload
service cgrates restart

and now i get 

cgr-engine -logger=*stdout
2018/02/16 15:10:37 CGRateS <2445fca> [INFO] Starting CGRateS CDRS service.
2018/02/16 15:10:37 CGRateS <2445fca> [INFO] <CDRC> No enabled CDRC clients
2018/02/16 15:10:37 CGRateS <2445fca> [INFO] Starting CGRateS Session service.
2018/02/16 15:10:37 method Call has wrong number of ins: 4
2018/02/16 15:10:37 method Call has wrong number of ins: 4
2018/02/16 15:10:37 method Call has wrong number of ins: 4
2018/02/16 15:10:37 method Call has wrong number of ins: 4
2018/02/16 15:10:37 CGRateS <2445fca> [INFO] <HTTP> enabling handler for JSON-RPC
2018/02/16 15:10:37 CGRateS <2445fca> [INFO] <HTTP> enabling handler for WebSocket connections
2018/02/16 15:10:37 CGRateS <2445fca> [INFO] <HTTP> start listening at <:2080>
2018/02/16 15:10:37 CGRateS <2445fca> [INFO] Starting User service.
2018/02/16 15:10:37 ServeJSON listen error:listen tcp :2012: bind: address already in use

Ta,



> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/cgrates/f51b4387-1c1d-4b14-9d08-fb1c32a79cf8%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "CGRateS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cgrates/Fuopn2umvGI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cgrates+unsubscribe@googlegroups.com.

To post to this group, send email to cgr...@googlegroups.com.

DanB

unread,
Feb 16, 2018, 10:25:47 AM2/16/18
to cgr...@googlegroups.com
Nordine,

Np. I see that your service is running now (the reason you got bind
already in use is due to the fact that you have already started CGRates
via service command.

You should get now cgr-console status.

Have fun!

DanB
> > > > > msgid/cgrates/9cbb25a6-6828-4dd5-87c9-
> > > > 03034719eca3%40googlegroups.com
> > > > > .
> > > > > For more options, visit https://groups.google.com/d/optout.
> > >
> > > --
> > > You received this message because you are subscribed to the
> > Google
> > > Groups "CGRateS" group.
> > > To unsubscribe from this group and stop receiving emails from it,
> > > send an email to cgrates+u...@googlegroups.com.
> > > To post to this group, send email to cgr...@googlegroups.com.
> > > To view this discussion on the web visit https://groups.google.co
> > m/d/
> > > msgid/cgrates/f51b4387-1c1d-4b14-9d08-
> > fb1c32a79cf8%40googlegroups.com
> > > .
> > > For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to a topic in
> > the Google Groups "CGRateS" group.
> > To unsubscribe from this topic, visit https://groups.google.com/d/t
> > opic/cgrates/Fuopn2umvGI/unsubscribe.
> > To unsubscribe from this group and all its topics, send an email to
> > cgrates+u...@googlegroups.com.
> > To post to this group, send email to cgr...@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/
> > d/msgid/cgrates/1518792252.2447.37.camel%40cgrates.org.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/cgrates/CAO2aRmaT5HZr-
> gkktYeV89e5LWkqvHF1HBff5xkr8ExB0Ep5Uw%40mail.gmail.com.

Omar Qr

unread,
Mar 2, 2018, 6:01:21 AM3/2/18
to CGRateS
Hello Dan,

I am Nordine's colleague and am currently testing CGRate's functionnalities. 
Don't you think that storDB and dataDB should be kept as seperate databases ? With the configuration you suggested, both databases are merged into the same aren't they ? 
I am raising this question because I am looking to use the CDR functionnality and in the documentation you mention the table cdrs_primary of the storDB and I can't find this table in this configuration. The only table mentionning cdr is cdr_stats and it doesn't seem to contain the records I add using the curl command given in the tutorial even if the command sends me the response "ok".

DanB

unread,
Mar 2, 2018, 7:19:31 AM3/2/18
to cgr...@googlegroups.com
Hi Omar,

You can find answers inline ...


On Fri, 2018-03-02 at 03:01 -0800, Omar Qr wrote:
> Hello Dan,
>
> I am Nordine's colleague and am currently testing CGRate's
> functionnalities.
> Don't you think that storDB and dataDB should be kept as seperate
> databases ? With the configuration you suggested, both databases are
> merged into the same aren't they ?
Whether the databases are kept together or separated, it is all a
matter of politics on your side. CGRateS should not be influenced by
this.
What I was suggested is that you use the same database in your cgr-
loader as you do in cgr-engine (cgr-loader and cgr-engine use different
configurations).
> I am raising this question because I am looking to use the CDR
> functionnality and in the documentation you mention the
> table cdrs_primary of the storDB and I can't find this table in this
> configuration. The only table mentionning cdr is cdr_stats and it
> doesn't seem to contain the records I add using the curl command
> given in the tutorial even if the command sends me the response "ok".

cdrs_primary was renamed to cdrs, you should find it there.
cdr_stats is something else.

I suggest you going over tutorial for your switch since you have there
complete sample of configs and tariff plans which should help you with
learning curve.

DanB

Omar Qr

unread,
Mar 2, 2018, 11:30:27 AM3/2/18
to CGRateS
Oh yes, sorry I didn't read all the previous discussions. 
Regarding CDR, I don't have a table called cdrs in my CGRateS db...

DanB

unread,
Mar 2, 2018, 11:32:30 AM3/2/18
to cgr...@googlegroups.com
Omar,

Which version of CGRateS are you using?

DanB
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/cgrates/45094df1-aef9-4092-8777-1b1a92d33ff4%40googlegroups.com

Omar Qr

unread,
Mar 5, 2018, 4:49:16 AM3/5/18
to CGRateS
Hello Dan,

I am using this link to download CGRateS http://www.cgrates.org/tmp_pkg/cgrates_0.9.1~rc8_amd64.deb

Omar Qr

unread,
Mar 5, 2018, 4:52:05 AM3/5/18
to CGRateS
Sorry, It is so weird, I reloaded the service and restarted it, and the cdrs table got created ...

DanB

unread,
Mar 6, 2018, 12:04:38 PM3/6/18
to cgr...@googlegroups.com
Omar,

OK, you should be on the right track in that case.
In rc8 we have cdrs and sessions_costs for CDRs.

DanB

PS: Since docs were written for previous versions of CGRateS, there are
changes that they got bit behind in some cases.

On Mon, 2018-03-05 at 01:49 -0800, Omar Qr wrote:
> Hello Dan,
>
Reply all
Reply to author
Forward
0 new messages