Merge branch 'develop' of github.com:ClusterCockpit/cc-metric-collector into develop

This commit is contained in:
Thomas Roehl 2022-02-07 13:47:06 +01:00
commit b7ee125942
2 changed files with 159 additions and 138 deletions

View File

@ -1,4 +1,12 @@
{ {
"cpufreq": {},
"cpufreq_cpuinfo": {},
"gpfs": {
"exclude_filesystem": [ "test_fs" ]
},
"loadavg": {
"exclude_metrics": [ "proc_total" ]
}
"tempstat": { "tempstat": {
"tag_override": { "tag_override": {
"hwmon0" : { "hwmon0" : {
@ -11,5 +19,3 @@
} }
} }
} }
}

View File

@ -21,8 +21,10 @@ type GpfsCollector struct {
metricCollector metricCollector
tags map[string]string tags map[string]string
config struct { config struct {
Mmpmon string `json:"mmpmon"` Mmpmon string `json:"mmpmon_path,omitempty"`
ExcludeFilesystem []string `json:"exclude_filesystem,omitempty"`
} }
skipFS map[string]struct{}
} }
func (m *GpfsCollector) Init(config json.RawMessage) error { func (m *GpfsCollector) Init(config json.RawMessage) error {
@ -54,6 +56,10 @@ func (m *GpfsCollector) Init(config json.RawMessage) error {
"type": "node", "type": "node",
"filesystem": "", "filesystem": "",
} }
m.skipFS = make(map[string]struct{})
for _, fs := range m.config.ExcludeFilesystem {
m.skipFS[fs] = struct{}{}
}
// GPFS / IBM Spectrum Scale file system statistics can only be queried by user root // GPFS / IBM Spectrum Scale file system statistics can only be queried by user root
user, err := user.Current() user, err := user.Current()
@ -108,7 +114,12 @@ func (m *GpfsCollector) Read(interval time.Duration, output chan lp.CCMetric) {
scanner := bufio.NewScanner(cmdStdout) scanner := bufio.NewScanner(cmdStdout)
for scanner.Scan() { for scanner.Scan() {
lineSplit := strings.Fields(scanner.Text()) lineSplit := strings.Fields(scanner.Text())
if lineSplit[0] == "_fs_io_s_" {
// Only process lines starting with _fs_io_s_
if lineSplit[0] != "_fs_io_s_" {
continue
}
key_value := make(map[string]string) key_value := make(map[string]string)
for i := 1; i < len(lineSplit); i += 2 { for i := 1; i < len(lineSplit); i += 2 {
key_value[lineSplit[i]] = lineSplit[i+1] key_value[lineSplit[i]] = lineSplit[i+1]
@ -128,6 +139,11 @@ func (m *GpfsCollector) Read(interval time.Duration, output chan lp.CCMetric) {
continue continue
} }
// Skip excluded filesystems
if _, skip := m.skipFS[filesystem]; skip {
continue
}
m.tags["filesystem"] = filesystem m.tags["filesystem"] = filesystem
// return code // return code
@ -258,7 +274,6 @@ func (m *GpfsCollector) Read(interval time.Duration, output chan lp.CCMetric) {
} }
} }
} }
}
func (m *GpfsCollector) Close() { func (m *GpfsCollector) Close() {
m.init = false m.init = false