fix race condition
This commit is contained in:
parent
388cac2a2f
commit
6c0ea7b743
|
@ -175,6 +175,13 @@ func (s *Sysstat) collect() error {
|
||||||
if len(s.Activities) == 0 {
|
if len(s.Activities) == 0 {
|
||||||
s.Activities = dfltActivities
|
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{}
|
options := []string{}
|
||||||
for _, act := range s.Activities {
|
for _, act := range s.Activities {
|
||||||
options = append(options, "-S", act)
|
options = append(options, "-S", act)
|
||||||
|
@ -194,13 +201,6 @@ func (s *Sysstat) collect() error {
|
||||||
// Sadf -p -- -p <option> tmpFile
|
// Sadf -p -- -p <option> tmpFile
|
||||||
// and parses the output to add it to the telegraf.Accumulator acc.
|
// 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 {
|
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)...)
|
cmd := execCommand(s.Sadf, s.sadfOptions(option)...)
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue