Added Status API all for each subsystem

This commit is contained in:
Anevo
2018-03-23 11:38:34 -04:00
committed by Dan Christian Bogos
parent d4e4e6162b
commit e81a3ae10b
21 changed files with 516 additions and 0 deletions

View File

@@ -1821,6 +1821,35 @@ func TestApierGetStorDBVesions(t *testing.T) {
}
}
func TestApierPing(t *testing.T) {
var reply string
if err := rater.Call(utils.StatSv1Ping, "", &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := rater.Call(utils.ResourceSv1Ping, "", &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := rater.Call(utils.SupplierSv1Ping, "", &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := rater.Call(utils.ThresholdSv1Ping, "", &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := rater.Call(utils.AttributeSv1Ping, "", &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
}
// Simply kill the engine after we are done with tests within this file
func TestApierStopEngine(t *testing.T) {
exec.Command("pkill", "cgr-engine").Run()

View File

@@ -98,3 +98,8 @@ func (alSv1 *AttributeSv1) ProcessEvent(ev *utils.CGREvent,
reply *engine.AttrSProcessEventReply) error {
return alSv1.attrS.V1ProcessEvent(ev, reply)
}
func (alSv1 *AttributeSv1) Ping(ign string, reply *string) error {
*reply = utils.Pong
return nil
}

View File

@@ -61,6 +61,7 @@ var sTestsAlsPrf = []func(t *testing.T){
testAttributeSSetAlsPrf,
testAttributeSUpdateAlsPrf,
testAttributeSRemAlsPrf,
testAttributeSPing,
testAttributeSKillEngine,
}
@@ -648,6 +649,15 @@ func testAttributeSRemAlsPrf(t *testing.T) {
}
}
func testAttributeSPing(t *testing.T) {
var resp string
if err := attrSRPC.Call(utils.AttributeSv1Ping, "", &resp); err != nil {
t.Error(err)
} else if resp != utils.Pong {
t.Error("Unexpected reply returned", resp)
}
}
func testAttributeSKillEngine(t *testing.T) {
if err := engine.KillEngine(alsPrfDelay); err != nil {
t.Error(err)

View File

@@ -22,6 +22,7 @@ import (
"time"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
"github.com/cgrates/ltcache"
)
@@ -92,3 +93,8 @@ func (chSv1 *CacheSv1) RemoveGroup(args *engine.ArgsGetGroup,
rply *string) (err error) {
return chSv1.cacheS.V1RemoveGroup(args, rply)
}
func (chSv1 *CacheSv1) Ping(ign string, reply *string) error {
*reply = utils.Pong
return nil
}

View File

@@ -105,3 +105,8 @@ func (apierV1 *ApierV1) RemoveResourceProfile(arg utils.TenantID, reply *string)
*reply = utils.OK
return nil
}
func (rsv1 *ResourceSv1) Ping(ign string, reply *string) error {
*reply = utils.Pong
return nil
}

View File

@@ -61,6 +61,7 @@ var sTestsRLSV1 = []func(t *testing.T){
testV1RsGetResourceProfileAfterUpdate,
testV1RsRemResourceProfile,
testV1RsGetResourceProfileAfterDelete,
testV1RsResourcePing,
testV1RsStopEngine,
}
@@ -684,6 +685,15 @@ func testV1RsGetResourceProfileAfterDelete(t *testing.T) {
}
}
func testV1RsResourcePing(t *testing.T) {
var resp string
if err := rlsV1Rpc.Call(utils.ResourceSv1Ping, "", &resp); err != nil {
t.Error(err)
} else if resp != utils.Pong {
t.Error("Unexpected reply returned", resp)
}
}
func testV1RsStopEngine(t *testing.T) {
if err := engine.KillEngine(resDelay); err != nil {
t.Error(err)

View File

@@ -133,3 +133,8 @@ func (ssv1 *SessionSv1) BiRPCV1GetPassiveSessions(clnt *rpc2.Client, args map[st
rply *[]*sessions.ActiveSession) error {
return ssv1.SMG.BiRPCV1GetPassiveSessions(clnt, args, rply)
}
func (ssv1 *SessionSv1) Ping(ign string, reply *string) error {
*reply = utils.Pong
return nil
}

View File

@@ -441,6 +441,15 @@ func TestSSv1ItProcessEvent(t *testing.T) {
}
}
func TestV1STSSessionPing(t *testing.T) {
var resp string
if err := sSv1BiRpc.Call(utils.SessionSv1Ping, "", &resp); err != nil {
t.Error(err)
} else if resp != utils.Pong {
t.Error("Unexpected reply returned", resp)
}
}
func TestSSv1ItStopCgrEngine(t *testing.T) {
if err := sSv1BiRpc.Close(); err != nil { // Close the connection so we don't get EOF warnings from client
t.Error(err)

View File

@@ -114,3 +114,8 @@ func (stsv1 *StatSv1) GetQueueStringMetrics(args *utils.TenantID, reply *map[str
func (stsv1 *StatSv1) GetQueueFloatMetrics(args *utils.TenantID, reply *map[string]float64) (err error) {
return stsv1.sS.V1GetQueueFloatMetrics(args, reply)
}
func (stSv1 *StatSv1) Ping(ign string, reply *string) error {
*reply = utils.Pong
return nil
}

View File

@@ -83,6 +83,7 @@ var sTestsStatSV1 = []func(t *testing.T){
testV1STSSetStatQueueProfile,
testV1STSUpdateStatQueueProfile,
testV1STSRemoveStatQueueProfile,
testV1STSStatsPing,
testV1STSStopEngine,
}
@@ -400,6 +401,15 @@ func testV1STSRemoveStatQueueProfile(t *testing.T) {
}
}
func testV1STSStatsPing(t *testing.T) {
var resp string
if err := stsV1Rpc.Call(utils.StatSv1Ping, "", &resp); err != nil {
t.Error(err)
} else if resp != utils.Pong {
t.Error("Unexpected reply returned", resp)
}
}
func testV1STSStopEngine(t *testing.T) {
if err := engine.KillEngine(statsDelay); err != nil {
t.Error(err)

View File

@@ -86,3 +86,8 @@ func (splv1 *SupplierSv1) GetSuppliers(args *engine.ArgsGetSuppliers,
reply *engine.SortedSuppliers) error {
return splv1.splS.V1GetSuppliers(args, reply)
}
func (splv1 *SupplierSv1) Ping(ign string, reply *string) error {
*reply = utils.Pong
return nil
}

View File

@@ -54,6 +54,7 @@ var sTestsSupplierSV1 = []func(t *testing.T){
testV1SplSSetSupplierProfiles,
testV1SplSUpdateSupplierProfiles,
testV1SplSRemSupplierProfiles,
testV1SplSupplierPing,
testV1SplSStopEngine,
}
@@ -368,6 +369,15 @@ func testV1SplSRemSupplierProfiles(t *testing.T) {
}
}
func testV1SplSupplierPing(t *testing.T) {
var resp string
if err := splSv1Rpc.Call(utils.SupplierSv1Ping, "", &resp); err != nil {
t.Error(err)
} else if resp != utils.Pong {
t.Error("Unexpected reply returned", resp)
}
}
func testV1SplSStopEngine(t *testing.T) {
if err := engine.KillEngine(100); err != nil {
t.Error(err)

View File

@@ -100,3 +100,8 @@ func (apierV1 *ApierV1) RemoveThresholdProfile(args *utils.TenantID, reply *stri
*reply = utils.OK
return nil
}
func (tSv1 *ThresholdSv1) Ping(ign string, reply *string) error {
*reply = utils.Pong
return nil
}

62
console/attribute_ping.go Normal file
View File

@@ -0,0 +1,62 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
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 <http://www.gnu.org/licenses/>
*/
package console
import "github.com/cgrates/cgrates/utils"
func init() {
c := &CmdAttributePing{
name: "attribute_ping",
rpcMethod: utils.AttributeSv1Ping,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdAttributePing struct {
name string
rpcMethod string
rpcParams *EmptyWrapper
*CommandExecuter
}
func (self *CmdAttributePing) Name() string {
return self.name
}
func (self *CmdAttributePing) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdAttributePing) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &EmptyWrapper{}
}
return self.rpcParams
}
func (self *CmdAttributePing) PostprocessRpcParams() error {
return nil
}
func (self *CmdAttributePing) RpcResult() interface{} {
var s string
return &s
}

62
console/resource_ping.go Normal file
View File

@@ -0,0 +1,62 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
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 <http://www.gnu.org/licenses/>
*/
package console
import "github.com/cgrates/cgrates/utils"
func init() {
c := &CmdResourcePing{
name: "resource_ping",
rpcMethod: utils.ResourceSv1Ping,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdResourcePing struct {
name string
rpcMethod string
rpcParams *EmptyWrapper
*CommandExecuter
}
func (self *CmdResourcePing) Name() string {
return self.name
}
func (self *CmdResourcePing) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdResourcePing) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &EmptyWrapper{}
}
return self.rpcParams
}
func (self *CmdResourcePing) PostprocessRpcParams() error {
return nil
}
func (self *CmdResourcePing) RpcResult() interface{} {
var s string
return &s
}

62
console/session_ping.go Normal file
View File

@@ -0,0 +1,62 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
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 <http://www.gnu.org/licenses/>
*/
package console
import "github.com/cgrates/cgrates/utils"
func init() {
c := &CmdSessionPing{
name: "session_ping",
rpcMethod: utils.SessionSv1Ping,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdSessionPing struct {
name string
rpcMethod string
rpcParams *EmptyWrapper
*CommandExecuter
}
func (self *CmdSessionPing) Name() string {
return self.name
}
func (self *CmdSessionPing) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdSessionPing) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &EmptyWrapper{}
}
return self.rpcParams
}
func (self *CmdSessionPing) PostprocessRpcParams() error {
return nil
}
func (self *CmdSessionPing) RpcResult() interface{} {
var s string
return &s
}

62
console/stats_ping.go Normal file
View File

@@ -0,0 +1,62 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
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 <http://www.gnu.org/licenses/>
*/
package console
import "github.com/cgrates/cgrates/utils"
func init() {
c := &CmdStatsPing{
name: "stats_ping",
rpcMethod: utils.StatSv1Ping,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdStatsPing struct {
name string
rpcMethod string
rpcParams *EmptyWrapper
*CommandExecuter
}
func (self *CmdStatsPing) Name() string {
return self.name
}
func (self *CmdStatsPing) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdStatsPing) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &EmptyWrapper{}
}
return self.rpcParams
}
func (self *CmdStatsPing) PostprocessRpcParams() error {
return nil
}
func (self *CmdStatsPing) RpcResult() interface{} {
var s string
return &s
}

62
console/supplier_ping.go Normal file
View File

@@ -0,0 +1,62 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
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 <http://www.gnu.org/licenses/>
*/
package console
import "github.com/cgrates/cgrates/utils"
func init() {
c := &CmdSupplierPing{
name: "supplier_ping",
rpcMethod: utils.SupplierSv1Ping,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdSupplierPing struct {
name string
rpcMethod string
rpcParams *EmptyWrapper
*CommandExecuter
}
func (self *CmdSupplierPing) Name() string {
return self.name
}
func (self *CmdSupplierPing) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdSupplierPing) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &EmptyWrapper{}
}
return self.rpcParams
}
func (self *CmdSupplierPing) PostprocessRpcParams() error {
return nil
}
func (self *CmdSupplierPing) RpcResult() interface{} {
var s string
return &s
}

62
console/threshold_ping.go Normal file
View File

@@ -0,0 +1,62 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
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 <http://www.gnu.org/licenses/>
*/
package console
import "github.com/cgrates/cgrates/utils"
func init() {
c := &CmdThresholdPing{
name: "threshold_ping",
rpcMethod: utils.ThresholdSv1Ping,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdThresholdPing struct {
name string
rpcMethod string
rpcParams *EmptyWrapper
*CommandExecuter
}
func (self *CmdThresholdPing) Name() string {
return self.name
}
func (self *CmdThresholdPing) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdThresholdPing) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &EmptyWrapper{}
}
return self.rpcParams
}
func (self *CmdThresholdPing) PostprocessRpcParams() error {
return nil
}
func (self *CmdThresholdPing) RpcResult() interface{} {
var s string
return &s
}

View File

@@ -65,6 +65,29 @@
],
},
"attributes": { // Attribute service
"enabled": true, // starts Alias service: <true|false>.
},
"resources": {
"enabled": true,
},
"stats": {
"enabled": true,
},
"thresholds": {
"enabled": true,
},
"suppliers": {
"enabled": true,
},
"aliases": {
"enabled": true, // start the CDR Server service: <true|false>
},

View File

@@ -531,6 +531,7 @@ const (
Append = "Append"
MetaRound = "*round"
LoaderS = "LoaderS"
Pong = "Pong"
)
//MetaMetrics
@@ -599,12 +600,14 @@ const (
// MetaSupplierAPIs
const (
SupplierSv1GetSuppliers = "SupplierSv1.GetSuppliers"
SupplierSv1Ping = "SupplierSv1.Ping"
)
// AttributeS APIs
const (
AttributeSv1GetAttributeForEvent = "AttributeSv1.GetAttributeForEvent"
AttributeSv1ProcessEvent = "AttributeSv1.ProcessEvent"
AttributeSv1Ping = "AttributeSv1.Ping"
)
//ThresholdS APIs
@@ -612,6 +615,7 @@ const (
ThresholdSv1ProcessEvent = "ThresholdSv1.ProcessEvent"
ThresholdSv1GetThreshold = "ThresholdSv1.GetThreshold"
ThresholdSv1GetThresholdIDs = "ThresholdSv1.GetThresholdIDs"
ThresholdSv1Ping = "ThresholdSv1.Ping"
)
//StatS APIs
@@ -619,6 +623,7 @@ const (
StatSv1ProcessEvent = "StatSv1.ProcessEvent"
StatSv1GetQueueIDs = "StatSv1.GetQueueIDs"
StatSv1GetQueueStringMetrics = "StatSv1.GetQueueStringMetrics"
StatSv1Ping = "StatSv1.Ping"
)
//ResourceS APIs
@@ -627,6 +632,7 @@ const (
ResourceSv1GetResourcesForEvent = "ResourceSv1.GetResourcesForEvent"
ResourceSv1AllocateResources = "ResourceSv1.AllocateResources"
ResourceSv1ReleaseResources = "ResourceSv1.ReleaseResources"
ResourceSv1Ping = "ResourceSv1.Ping"
)
//SessionS APIs
@@ -644,6 +650,7 @@ const (
SMGenericV1InitiateSession = "SMGenericV1.InitiateSession"
SMGenericV2InitiateSession = "SMGenericV2.InitiateSession"
SMGenericV2UpdateSession = "SMGenericV2.UpdateSession"
SessionSv1Ping = "SessionSv1.Ping"
)
// Cache