status for rater

This commit is contained in:
Radu Ioan Fericean
2012-03-29 16:44:49 +03:00
parent b88bf2702c
commit b3da66f289
4 changed files with 58 additions and 5 deletions

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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.
*/

View File

@@ -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.