diff --git a/cmd/balancer/jsonrpc_responder.go b/cmd/balancer/jsonrpc_responder.go
index 4633dbc11..05816cfb2 100644
--- a/cmd/balancer/jsonrpc_responder.go
+++ b/cmd/balancer/jsonrpc_responder.go
@@ -18,11 +18,13 @@ along with this program. If not, see
package main
import (
+ "fmt"
"github.com/rif/cgrates/timespans"
"log"
"net"
"net/rpc"
"net/rpc/jsonrpc"
+ "runtime"
)
type Responder byte
@@ -50,7 +52,7 @@ func (r *Responder) DebitSeconds(arg timespans.CallDescriptor, replay *float64)
return
}
-func (r *Responder) GetMaxSessionTime(arg timespans.CallDescriptor, replay *float64) (err error) {
+func (r *Responder) GetMaxSessionTimae(arg timespans.CallDescriptor, replay *float64) (err error) {
*replay = CallMethod(&arg, "Responder.GetMaxSessionTime")
return
}
@@ -75,6 +77,13 @@ func (r *Responder) ResetUserBudget(arg timespans.CallDescriptor, replay *float6
return
}
+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
+}
+
/*
Creates the json rpc server.
*/
diff --git a/cmd/balancer/registration.go b/cmd/balancer/registration.go
index 9e4d2c789..a13215bee 100644
--- a/cmd/balancer/registration.go
+++ b/cmd/balancer/registration.go
@@ -51,7 +51,7 @@ func StopSingnalHandler() {
log.Printf("Caught signal %v, sending shutdownto raters\n", sig)
var reply string
for i, client := range raterList.clientConnections {
- client.Call("Storage.Shutdown", "", &reply)
+ client.Call("Responder.Shutdown", "", &reply)
log.Printf("Shutdown rater %v: %v ", raterList.clientAddresses[i], reply)
}
os.Exit(1)
diff --git a/cmd/cgrates/cgrates.go b/cmd/cgrates/cgrates.go
index c995cc4be..693ab4c8c 100644
--- a/cmd/cgrates/cgrates.go
+++ b/cmd/cgrates/cgrates.go
@@ -1,7 +1,25 @@
+/*
+Rating system designed to be used in VoIP Carriers World
+Copyright (C) 2012 Radu Ioan Fericean
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
package main
import (
"flag"
+ "fmt"
"github.com/rif/cgrates/timespans"
"log"
"net/rpc/jsonrpc"
@@ -17,6 +35,7 @@ var (
dest = flag.String("dest", "0256", "Destination prefix")
ts = flag.String("ts", "2012-02-09T00:00:00Z", "Time start")
te = flag.String("te", "2012-02-09T00:10:00Z", "Time end")
+ amount = flag.Float64("amount", 100, "Amount for different operations")
)
func main() {
@@ -40,16 +59,27 @@ func main() {
DestinationPrefix: *dest,
TimeStart: timestart,
TimeEnd: timeend,
+ Amount: *amount,
}
- result := timespans.CallCost{}
switch flag.Arg(0) {
case "getcost":
+ result := timespans.CallCost{}
if err = client.Call("Responder.GetCost", cd, &result); err == nil {
- log.Print(result)
+ fmt.Println(result)
+ }
+ case "getmaxsessiontime":
+ var result float64
+ if err = client.Call("Responder.GetMaxSessionTime", cd, &result); err == nil {
+ fmt.Println(result)
+ }
+ case "status":
+ var result string
+ if err = client.Call("Responder.Status", cd, &result); err == nil {
+ fmt.Println(result)
}
default:
- log.Print("hello!")
+ fmt.Print("hello!")
}
if err != nil {
log.Print(err)