Skip to content

Commit

Permalink
fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
zbindenren authored and sparrc committed Apr 7, 2016
1 parent 17033b3 commit 264ac0b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions plugins/inputs/sysstat/sysstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ func (s *Sysstat) collect() error {
if len(s.Activities) == 0 {
s.Activities = dfltActivities
}
if len(s.Sadf) == 0 {
sadf, err := exec.LookPath("sadf")
if err != nil {
return errors.New("sadf not in $PATH, configure path to sadf")
}
s.Sadf = sadf
}
options := []string{}
for _, act := range s.Activities {
options = append(options, "-S", act)
Expand All @@ -194,13 +201,6 @@ func (s *Sysstat) collect() error {
// 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 {
if len(s.Sadf) == 0 {
sadf, err := exec.LookPath("sadf")
if err != nil {
return errors.New("sadf not in $PATH, configure path to sadf")
}
s.Sadf = sadf
}
cmd := execCommand(s.Sadf, s.sadfOptions(option)...)
stdout, err := cmd.StdoutPipe()
if err != nil {
Expand Down

0 comments on commit 264ac0b

Please sign in to comment.