Add CAPs counting to cgr-console status command

This commit is contained in:
arberkatellari
2024-03-01 12:58:00 +02:00
committed by Dan Christian Bogos
parent 49d6b8d565
commit 9be32c36da
8 changed files with 126 additions and 5 deletions

View File

@@ -49,6 +49,7 @@ func NewCoreService(cfg *config.CGRConfig, caps *engine.Caps, fileCPU io.Closer,
CapsStats: st,
fileCPU: fileCPU,
fileMEM: fileMem,
caps: caps,
}
}
@@ -61,6 +62,7 @@ type CoreService struct {
fileMEM string
fileCPU io.Closer
fileMx sync.Mutex
caps *engine.Caps
}
// Shutdown is called to shutdown the service
@@ -141,6 +143,12 @@ func (cS *CoreService) V1Status(_ *context.Context, _ *utils.TenantWithAPIOpts,
}
response[utils.RunningSince] = utils.GetStartTime()
response[utils.GoVersion] = runtime.Version()
if cS.cfg.CoreSCfg().Caps != 0 {
response[utils.CAPSAllocated] = cS.caps.Allocated()
if cS.cfg.CoreSCfg().CapsStatsInterval != 0 {
response[utils.CAPSPeak] = cS.CapsStats.GetPeak()
}
}
*reply = response
return
}

View File

@@ -47,11 +47,12 @@ func TestNewCoreService(t *testing.T) {
stopMemPrf: stopMemPrf,
cfg: cfgDflt,
CapsStats: sts,
caps: caps,
}
rcv := NewCoreService(cfgDflt, caps, nil, "/tmp", stopchan, shdWg, stopMemPrf, shdChan)
if !reflect.DeepEqual(expected, rcv) {
t.Errorf("Expected %+v, received %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
t.Errorf("Expected %+v, received %+v", expected, rcv)
}
close(stopchan)
//shut down the service