Gather IPMI metrics concurrently from list of servers (#4352)

This commit is contained in:
Greg 2018-07-02 20:06:57 -06:00 committed by Daniel Nelson
parent 2da223390a
commit 4e440b36fd
1 changed files with 11 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import (
"os/exec"
"strconv"
"strings"
"sync"
"time"
"github.com/influxdata/telegraf"
@ -61,13 +62,18 @@ func (m *Ipmi) Gather(acc telegraf.Accumulator) error {
}
if len(m.Servers) > 0 {
wg := sync.WaitGroup{}
for _, server := range m.Servers {
err := m.parse(acc, server)
wg.Add(1)
go func(a telegraf.Accumulator, s string) {
defer wg.Done()
err := m.parse(a, s)
if err != nil {
acc.AddError(err)
continue
a.AddError(err)
}
}(acc, server)
}
wg.Wait()
} else {
err := m.parse(acc, "")
if err != nil {