Skip to content

Commit

Permalink
Gather IPMI metrics concurrently from list of servers (#4352)
Browse files Browse the repository at this point in the history
  • Loading branch information
glinton authored and danielnelson committed Jul 3, 2018
1 parent 2da2233 commit 4e440b3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions plugins/inputs/ipmi_sensor/ipmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os/exec"
"strconv"
"strings"
"sync"
"time"

"github.com/influxdata/telegraf"
Expand Down Expand Up @@ -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)
if err != nil {
acc.AddError(err)
continue
}
wg.Add(1)
go func(a telegraf.Accumulator, s string) {
defer wg.Done()
err := m.parse(a, s)
if err != nil {
a.AddError(err)
}
}(acc, server)
}
wg.Wait()
} else {
err := m.parse(acc, "")
if err != nil {
Expand Down

0 comments on commit 4e440b3

Please sign in to comment.