Skip to content

Commit

Permalink
Use C locale when running sadf
Browse files Browse the repository at this point in the history
fixes #1911
  • Loading branch information
danielnelson committed Apr 20, 2017
1 parent 3690e1b commit 98eaf10
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions plugins/inputs/sysstat/sysstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,26 @@ func (s *Sysstat) collect() error {
return nil
}

func filterEnviron(env []string, prefix string) []string {
newenv := env[:0]
for _, envvar := range env {
if !strings.HasPrefix(envvar, prefix) {
newenv = append(newenv, envvar)
}
}
return newenv
}

// parse runs Sadf on the previously saved tmpFile:
// Sadf -p -- -p <option> tmpFile
// and parses the output to add it to the telegraf.Accumulator acc.
func (s *Sysstat) parse(acc telegraf.Accumulator, option string, ts time.Time) error {
cmd := execCommand(s.Sadf, s.sadfOptions(option)...)
env := os.Environ()
env = filterEnviron(env, "LANG")
env = filterEnviron(env, "LC_")
env = append(env, "LANG=C")
cmd.Env = env
stdout, err := cmd.StdoutPipe()
if err != nil {
return err
Expand Down

0 comments on commit 98eaf10

Please sign in to comment.