mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-24 22:59:06 +01:00
Cleanup
This commit is contained in:
parent
a3ad9d0cb0
commit
5060497abd
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"numastats": {},
|
||||||
"cpufreq": {},
|
"cpufreq": {},
|
||||||
"cpufreq_cpuinfo": {},
|
"cpufreq_cpuinfo": {},
|
||||||
"gpfs": {
|
"gpfs": {
|
||||||
|
@ -61,8 +61,8 @@ func (m *NUMAStatsCollector) Init(config json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop for all NUMA node directories
|
// Loop for all NUMA node directories
|
||||||
baseDir := "/sys/devices/system/node"
|
base := "/sys/devices/system/node/node"
|
||||||
globPattern := filepath.Join(baseDir, "node[0-9]*")
|
globPattern := base + "[0-9]*"
|
||||||
dirs, err := filepath.Glob(globPattern)
|
dirs, err := filepath.Glob(globPattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to glob files with pattern '%s'", globPattern)
|
return fmt.Errorf("unable to glob files with pattern '%s'", globPattern)
|
||||||
@ -72,7 +72,7 @@ func (m *NUMAStatsCollector) Init(config json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
m.topology = make([]NUMAStatsCollectorTopolgy, 0, len(dirs))
|
m.topology = make([]NUMAStatsCollectorTopolgy, 0, len(dirs))
|
||||||
for _, dir := range dirs {
|
for _, dir := range dirs {
|
||||||
node := strings.TrimPrefix(dir, "/sys/devices/system/node/node")
|
node := strings.TrimPrefix(dir, base)
|
||||||
file := filepath.Join(dir, "numastat")
|
file := filepath.Join(dir, "numastat")
|
||||||
m.topology = append(m.topology,
|
m.topology = append(m.topology,
|
||||||
NUMAStatsCollectorTopolgy{
|
NUMAStatsCollectorTopolgy{
|
||||||
@ -103,6 +103,8 @@ func (m *NUMAStatsCollector) Read(interval time.Duration, output chan lp.CCMetri
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
|
|
||||||
|
// Read line by line
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
split := strings.Fields(scanner.Text())
|
split := strings.Fields(scanner.Text())
|
||||||
if len(split) != 2 {
|
if len(split) != 2 {
|
||||||
@ -116,7 +118,13 @@ func (m *NUMAStatsCollector) Read(interval time.Duration, output chan lp.CCMetri
|
|||||||
fmt.Sprintf("Read(): Failed to convert %s='%s' to int64: %v", key, split[1], err))
|
fmt.Sprintf("Read(): Failed to convert %s='%s' to int64: %v", key, split[1], err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
y, err := lp.New("numastats_"+key, t.tagSet, m.meta, map[string]interface{}{"value": value}, now)
|
y, err := lp.New(
|
||||||
|
"numastats_"+key,
|
||||||
|
t.tagSet,
|
||||||
|
m.meta,
|
||||||
|
map[string]interface{}{"value": value},
|
||||||
|
now,
|
||||||
|
)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
output <- y
|
output <- y
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user