0.3.0: leofs & lustre2

This commit is contained in:
Cameron Sparr 2015-12-14 17:11:54 -06:00
parent deb059e7a8
commit c04f37bb54
2 changed files with 10 additions and 7 deletions

View File

@ -197,6 +197,8 @@ func (l *LeoFS) gatherServer(endpoint string, serverType ServerType, acc plugins
"node": nodeNameTrimmed, "node": nodeNameTrimmed,
} }
i := 0 i := 0
fields := make(map[string]interface{})
for scanner.Scan() { for scanner.Scan() {
key := KeyMapping[serverType][i] key := KeyMapping[serverType][i]
val, err := retrieveTokenAfterColon(scanner.Text()) val, err := retrieveTokenAfterColon(scanner.Text())
@ -207,9 +209,10 @@ func (l *LeoFS) gatherServer(endpoint string, serverType ServerType, acc plugins
if err != nil { if err != nil {
return fmt.Errorf("Unable to parse the value:%s, err:%s", val, err) return fmt.Errorf("Unable to parse the value:%s, err:%s", val, err)
} }
acc.Add(key, fVal, tags) fields[key] = fVal
i++ i++
} }
acc.AddFields("leofs", fields, tags)
return nil return nil
} }

View File

@ -149,19 +149,19 @@ func (l *Lustre2) GetLustreProcStats(fileglob string, wanted_fields []*mapping,
return err return err
} }
fields := make(map[string]interface{})
for _, line := range lines { for _, line := range lines {
fields := strings.Fields(line) parts := strings.Fields(line)
for _, wanted := range wanted_fields { for _, wanted := range wanted_fields {
var data uint64 var data uint64
if fields[0] == wanted.inProc { if parts[0] == wanted.inProc {
wanted_field := wanted.field wanted_field := wanted.field
// if not set, assume field[1]. Shouldn't be field[0], as // if not set, assume field[1]. Shouldn't be field[0], as
// that's a string // that's a string
if wanted_field == 0 { if wanted_field == 0 {
wanted_field = 1 wanted_field = 1
} }
data, err = strconv.ParseUint((fields[wanted_field]), 10, 64) data, err = strconv.ParseUint((parts[wanted_field]), 10, 64)
if err != nil { if err != nil {
return err return err
} }
@ -169,11 +169,11 @@ func (l *Lustre2) GetLustreProcStats(fileglob string, wanted_fields []*mapping,
if wanted.reportAs != "" { if wanted.reportAs != "" {
report_name = wanted.reportAs report_name = wanted.reportAs
} }
acc.Add(report_name, data, tags) fields[report_name] = data
} }
} }
} }
acc.AddFields("lustre2", fields)
} }
return nil return nil
} }