Add skip_filesystem configuration

This commit is contained in:
Holger Obermaier 2022-02-07 13:30:01 +01:00
parent c313055570
commit ead7117cad
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": {
"tag_override": {
"hwmon0" : {
@ -11,5 +19,3 @@
}
}
}
}

View File

@ -21,8 +21,10 @@ type GpfsCollector struct {
metricCollector
tags map[string]string
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 {
@ -54,6 +56,10 @@ func (m *GpfsCollector) Init(config json.RawMessage) error {
"type": "node",
"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
user, err := user.Current()
@ -108,7 +114,12 @@ func (m *GpfsCollector) Read(interval time.Duration, output chan lp.CCMetric) {
scanner := bufio.NewScanner(cmdStdout)
for scanner.Scan() {
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)
for i := 1; i < len(lineSplit); i += 2 {
key_value[lineSplit[i]] = lineSplit[i+1]
@ -128,6 +139,11 @@ func (m *GpfsCollector) Read(interval time.Duration, output chan lp.CCMetric) {
continue
}
// Skip excluded filesystems
if _, skip := m.skipFS[filesystem]; skip {
continue
}
m.tags["filesystem"] = filesystem
// return code
@ -258,7 +274,6 @@ func (m *GpfsCollector) Read(interval time.Duration, output chan lp.CCMetric) {
}
}
}
}
func (m *GpfsCollector) Close() {
m.init = false