Gather IPMI metrics concurrently from list of servers (#4352)
This commit is contained in:
parent
2da223390a
commit
4e440b36fd
|
@ -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)
|
||||||
if err != nil {
|
go func(a telegraf.Accumulator, s string) {
|
||||||
acc.AddError(err)
|
defer wg.Done()
|
||||||
continue
|
err := m.parse(a, s)
|
||||||
}
|
if err != nil {
|
||||||
|
a.AddError(err)
|
||||||
|
}
|
||||||
|
}(acc, server)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
} else {
|
} else {
|
||||||
err := m.parse(acc, "")
|
err := m.parse(acc, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue