mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 23:19:06 +01:00
remove prefix enumeration like 01-...
This commit is contained in:
parent
ed68baeada
commit
3e91a37dee
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -100,6 +101,7 @@ func (r *IPMIReceiver) doReadMetric() {
|
|||||||
idxUnits
|
idxUnits
|
||||||
idxEvent
|
idxEvent
|
||||||
)
|
)
|
||||||
|
numPrefixRegex := regexp.MustCompile("^[[:digit:]][[:digit:]]-(.*)$")
|
||||||
scanner := bufio.NewScanner(stdout)
|
scanner := bufio.NewScanner(stdout)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
// Read host
|
// Read host
|
||||||
@ -124,7 +126,13 @@ func (r *IPMIReceiver) doReadMetric() {
|
|||||||
|
|
||||||
metric := strings.ToLower(v2[idxType])
|
metric := strings.ToLower(v2[idxType])
|
||||||
name := strings.ToLower(
|
name := strings.ToLower(
|
||||||
strings.Replace(v2[idxName], " ", "_", -1))
|
strings.Replace(
|
||||||
|
strings.TrimSpace(
|
||||||
|
v2[idxName]), " ", "_", -1))
|
||||||
|
// remove prefix enumeration like 01-...
|
||||||
|
if v := numPrefixRegex.FindStringSubmatch(name); v != nil {
|
||||||
|
name = v[1]
|
||||||
|
}
|
||||||
unit := v2[idxUnits]
|
unit := v2[idxUnits]
|
||||||
if unit == "Watts" {
|
if unit == "Watts" {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user