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