Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up some code formatting #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ type AppConfiguration struct {
XmsLicensesURL string `default:"http://localhost:10080/resource/licenses"`

// C5 Configuration
SIPProxydEnabled bool
SIPProxydExtEnabled bool
SIPProxydURL string `default:"http://127.0.0.1:9980/c5/proxy/commands?49&1&-v"`
SIPProxydTrunksEnabled bool
SIPProxydTrunkStatsURL string `default:"http://127.0.0.1:9980/c5/proxy/commands?3&7&309"`
SIPProxydTrunkLimitsURL string `default:"http://127.0.0.1:9980/c5/proxy/commands?3&7&368"`
SIPProxydSPCountersURL string `default:"http://127.0.0.1:9980/c5/proxy/commands?4&0&spAll"`
SIPProxydEnabled bool
SIPProxydExtEnabled bool
SIPProxydURL string `default:"http://127.0.0.1:9980/c5/proxy/commands?49&1&-v"`
SIPProxydTrunksEnabled bool
SIPProxydTrunkStatsURL string `default:"http://127.0.0.1:9980/c5/proxy/commands?3&7&309"`
SIPProxydTrunkLimitsURL string `default:"http://127.0.0.1:9980/c5/proxy/commands?3&7&368"`
SIPProxydSPCountersURL string `default:"http://127.0.0.1:9980/c5/proxy/commands?4&0&spAll"`
SIPProxydClSPCountersURL string `default:"http://127.0.0.1:9980/c5/proxy/commands?4&0&spAllCl"`
ACDQueuedEnabled bool
ACDQueuedURL string `default:"http://127.0.0.1:9982/c5/proxy/commands?49&1&-v"`
RegistrardEnabled bool
RegistrardURL string `default:"http://127.0.0.1:9984/c5/proxy/commands?49&1&-v"`
NotificationEnabled bool
NotificationURL string `default:"http://127.0.0.1:9988/c5/proxy/commands?49&1&-v"`
CstaEnabled bool
CstaURL string `default:"http://127.0.0.1:9986/c5/proxy/commands?49&1&-v"`
ACDQueuedEnabled bool
ACDQueuedURL string `default:"http://127.0.0.1:9982/c5/proxy/commands?49&1&-v"`
RegistrardEnabled bool
RegistrardURL string `default:"http://127.0.0.1:9984/c5/proxy/commands?49&1&-v"`
NotificationEnabled bool
NotificationURL string `default:"http://127.0.0.1:9988/c5/proxy/commands?49&1&-v"`
CstaEnabled bool
CstaURL string `default:"http://127.0.0.1:9986/c5/proxy/commands?49&1&-v"`

// Misc
GoCollectorEnabled bool
GoCollectorEnabled bool
}
36 changes: 18 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var metricSet *metrics.Set

// Fix missing cmpGrp label when C5 component is shutdown
var gCmpGrp map[string]MetricAttribute
var gDc map[string]MetricAttribute
var gDc map[string]MetricAttribute
var attributesMtx sync.Mutex

type eventCounter struct {
Expand Down Expand Up @@ -98,7 +98,7 @@ func buildMetricName(prefix string, name string, attrs []MetricAttribute) string
if len(attrs) > 0 {
labels := string("{")
for _, v := range attrs {
if (len(v.name) > 0 && len(v.value) > 0) {
if len(v.name) > 0 && len(v.value) > 0 {
labels += v.name + string(`="`) + v.value + `",`
}
}
Expand Down Expand Up @@ -484,21 +484,21 @@ func processC5StateCounter(prefix string, lines []interface{}, attrs []MetricAtt
// processC5CounterMetrics will parse a counter output of type EVENT and USAGE for
// a specific C5 metric.
//
// {
// "proxyResponseTimeStampAndState:" : "2021-02-25 10:31:48 active",
// "clusterInfo" : "DC=1 {Wien} CompGrpId=31 [VAS-1] (masterId=8)",
// "counterName" : "BT_CALLS_LIMIT_REACHED",
// "counterType" : "EVENT",
// "absoluteValue" : 0,
// "currentValue" : 0,
// "lastValue" : 0,
// "tableValues" : [
// "name absolute curr last",
// "trunkname1.ipcentrex.internal 0 0 0",
// "trunk2.otherprovider.at 0 0 0",
// ],
// "tableCountInfo" : "curComponentCount2: 14 (10000) "
// }
// {
// "proxyResponseTimeStampAndState:" : "2021-02-25 10:31:48 active",
// "clusterInfo" : "DC=1 {Wien} CompGrpId=31 [VAS-1] (masterId=8)",
// "counterName" : "BT_CALLS_LIMIT_REACHED",
// "counterType" : "EVENT",
// "absoluteValue" : 0,
// "currentValue" : 0,
// "lastValue" : 0,
// "tableValues" : [
// "name absolute curr last",
// "trunkname1.ipcentrex.internal 0 0 0",
// "trunk2.otherprovider.at 0 0 0",
// ],
// "tableCountInfo" : "curComponentCount2: 14 (10000) "
// }
func processC5CounterMetrics(basePrefix string, data c5CounterResponse, attrs []MetricAttribute) {
const event, usage string = "EVENT", "USAGE"
prefix := basePrefix + "_" + strings.ToLower(data.CounterName)
Expand Down Expand Up @@ -856,7 +856,7 @@ func main() {
}
})

if (conf.SIPProxydExtEnabled) {
if conf.SIPProxydExtEnabled {
// dedicated endpoint for per-service-provider metrics
http.HandleFunc("/metrics-extended", func(httpResponse http.ResponseWriter, req *http.Request) {
metricSet = metrics.NewSet()
Expand Down
18 changes: 9 additions & 9 deletions service_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
)

func parseServiceProviderCounter(line string, id string) usageCounter {
/*
"name current min max lMin lMax lAvg total",
"BT_ACTIVE_CALLS 0 0 0 0 0 0 0",
"CENTREX_ACTIVE_CALLS 0 0 0 0 0 0 0",
*/
/*
"name current min max lMin lMax lAvg total",
"BT_ACTIVE_CALLS 0 0 0 0 0 0 0",
"CENTREX_ACTIVE_CALLS 0 0 0 0 0 0 0",
*/
parts := strings.Fields(line)
if len(parts) < 8 {
return usageCounter{}
Expand Down Expand Up @@ -67,14 +67,14 @@ func fetchServiceProviderCounters(prefix, url string, wg *sync.WaitGroup) {
attrs := []MetricAttribute{{"dc", dc}, {"cmpGrp", cmpGrp}}

for key, value := range counters {
if (strings.HasPrefix(key, "spCounterTable")) {
if strings.HasPrefix(key, "spCounterTable") {
matches := re.FindStringSubmatch(key)
if len(matches) > 1 {
serviceProvider := matches[1]

for i := range value.([]interface {}) {
line := value.([]interface {})[i].(string)
if (!strings.HasPrefix(line, "name")) {
for i := range value.([]interface{}) {
line := value.([]interface{})[i].(string)
if !strings.HasPrefix(line, "name") {
ctr := parseServiceProviderCounter(line, serviceProvider)
setUsageMetric(prefix, ctr, append(attrs, MetricAttribute{"sp", serviceProvider}))
}
Expand Down
Loading