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" "os/exec"
"strconv" "strconv"
"strings" "strings"
"sync"
"time" "time"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
@ -61,13 +62,18 @@ func (m *Ipmi) Gather(acc telegraf.Accumulator) error {
} }
if len(m.Servers) > 0 { if len(m.Servers) > 0 {
wg := sync.WaitGroup{}
for _, server := range m.Servers { 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 { if err != nil {
acc.AddError(err) a.AddError(err)
continue
} }
}(acc, server)
} }
wg.Wait()
} else { } else {
err := m.parse(acc, "") err := m.parse(acc, "")
if err != nil { if err != nil {