Skip to content

Commit

Permalink
darwin net plugin fix, really need to godep vendor gopsutil
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Sep 10, 2015
1 parent f7a4317 commit d8482cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ will still be backwards compatible if only `url` is specified.
- [#170](https:/influxdb/telegraf/issues/170): Systemd support
- [#175](https:/influxdb/telegraf/issues/175): Set write precision before gathering metrics
- [#178](https:/influxdb/telegraf/issues/178): redis plugin, multiple server thread hang bug
- Fix net plugin on darwin

## v0.1.8 [2015-09-04]

Expand Down
20 changes: 13 additions & 7 deletions plugins/system/ps/net/net_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"strings"

"github.com/influxdb/telegraf/plugins/system/ps/common"
"github.com/shirou/gopsutil/common"
)

func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
Expand All @@ -26,7 +26,7 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
// skip first line
continue
}
if common.StringContains(exists, values[0]) {
if common.StringsHas(exists, values[0]) {
// skip if already get
continue
}
Expand All @@ -38,11 +38,14 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
base = 0
}

parsed := make([]uint64, 0, 3)
parsed := make([]uint64, 0, 6)
vv := []string{
values[base+3], // PacketsRecv
values[base+4], // Errin
values[base+5], // Dropin
values[base+3], // Ipkts == PacketsRecv
values[base+4], // Ierrs == Errin
values[base+5], // Ibytes == BytesRecv
values[base+6], // Opkts == PacketsSent
values[base+7], // Oerrs == Errout
values[base+8], // Obytes == BytesSent
}
for _, target := range vv {
if target == "-" {
Expand All @@ -61,7 +64,10 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
Name: values[0],
PacketsRecv: parsed[0],
Errin: parsed[1],
Dropin: parsed[2],
BytesRecv: parsed[2],
PacketsSent: parsed[3],
Errout: parsed[4],
BytesSent: parsed[5],
}
ret = append(ret, n)
}
Expand Down

0 comments on commit d8482cc

Please sign in to comment.