From b3da66f289036bcc5fef13b6ee2bef8041348cb7 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Thu, 29 Mar 2012 16:44:49 +0300 Subject: [PATCH] status for rater --- cmd/balancer/jsonrpc_responder.go | 7 ++++++- cmd/cgrates/cgrates.go | 12 ++++++++++- cmd/rater/rater.go | 9 ++++++++ docs/tutorial.rst | 35 ++++++++++++++++++++++++++++--- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/cmd/balancer/jsonrpc_responder.go b/cmd/balancer/jsonrpc_responder.go index 44cf9a3ab..0b906415c 100644 --- a/cmd/balancer/jsonrpc_responder.go +++ b/cmd/balancer/jsonrpc_responder.go @@ -80,7 +80,12 @@ func (r *Responder) ResetUserBudget(arg timespans.CallDescriptor, replay *float6 func (r *Responder) Status(arg timespans.CallDescriptor, replay *string) (err error) { memstats := new(runtime.MemStats) runtime.ReadMemStats(memstats) - *replay = fmt.Sprintf("memstats before GC: %dKb footprint: %dKb", memstats.HeapAlloc/1024, memstats.Sys/1024) + *replay = "Connected raters:\n" + for _, rater := range raterList.clientAddresses { + log.Print(rater) + *replay += fmt.Sprintf("%v\n", rater) + } + *replay += fmt.Sprintf("memstats before GC: %dKb footprint: %dKb", memstats.HeapAlloc/1024, memstats.Sys/1024) return } diff --git a/cmd/cgrates/cgrates.go b/cmd/cgrates/cgrates.go index 6c0a05601..6b3c518e1 100644 --- a/cmd/cgrates/cgrates.go +++ b/cmd/cgrates/cgrates.go @@ -115,7 +115,17 @@ func main() { } default: - fmt.Print("hello!") + fmt.Println("List of commands:") + fmt.Println("\tgetcost") + fmt.Println("\tgetmaxsessiontime") + fmt.Println("\tdebitbalance") + fmt.Println("\tdebitsms") + fmt.Println("\tdebitseconds") + fmt.Println("\taddvolumediscountseconds") + fmt.Println("\tresetvolumediscountseconds") + fmt.Println("\taddrecievedcallseconds") + fmt.Println("\tresetuserbudget") + fmt.Println("\tstatus") } if err != nil { log.Print(err) diff --git a/cmd/rater/rater.go b/cmd/rater/rater.go index 82ba6e074..518f03f9f 100644 --- a/cmd/rater/rater.go +++ b/cmd/rater/rater.go @@ -19,12 +19,14 @@ package main import ( "flag" + "fmt" "github.com/rif/cgrates/timespans" "log" "net" "net/rpc" "net/rpc/jsonrpc" "os" + "runtime" ) var ( @@ -117,6 +119,13 @@ func (s *Responder) ResetUserBudget(cd timespans.CallDescriptor, reply *float64) return err } +func (r *Responder) Status(arg timespans.CallDescriptor, replay *string) (err error) { + memstats := new(runtime.MemStats) + runtime.ReadMemStats(memstats) + *replay = fmt.Sprintf("memstats before GC: %dKb footprint: %dKb", memstats.HeapAlloc/1024, memstats.Sys/1024) + return +} + /* RPC method that triggers rater shutdown in case of balancer exit. */ diff --git a/docs/tutorial.rst b/docs/tutorial.rst index dfc25d758..2963b2669 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -60,9 +60,10 @@ Instalation After the go environment is installed_ and setup_ just issue the following commands: :: - go get -v github.com/rif/cgrates/cmd/rater - go get -v github.com/rif/cgrates/cmd/balancer - go get -v github.com/rif/cgrates/cmd/loader + go get github.com/rif/cgrates/cmd/rater + go get github.com/rif/cgrates/cmd/balancer + go get github.com/rif/cgrates/cmd/loader + go get github.com/rif/cgrates/cmd/cgrates After that navigate @@ -94,6 +95,34 @@ rater -listen="127.0.0.1:1234": listening address host:port -balancer="127.0.0.1:2000": balancer address host:port +gcrates + The cgrates is a command line tool used to access the balancer (or the rater directly) to call all the API methods offered by CGRateS. +:: + + rif@grace:~$ cgrates --help + Usage of cgrates: + -amount=100: Amount for different operations + -balancer="127.0.0.1:2001": balancer address host:port + -cstmid="vdf": Customer identificator + -dest="0256": Destination prefix + -subject="rif": The client who made the call + -te="2012-02-09T00:10:00Z": Time end + -tor=0: Type of record + -ts="2012-02-09T00:00:00Z": Time start + + rif@grace:~$ cgrates + List of commands: + getcost + getmaxsessiontime + debitbalance + debitsms + debitseconds + addvolumediscountseconds + resetvolumediscountseconds + addrecievedcallseconds + resetuserbudget + status + loader The loader is the most configurable tool because it has options for each of the three supported databases (kyoto, redis and mongodb). Apart from that multi-database options it is quite easy to be used.