Skip to content

Commit

Permalink
Add network protocol stats to the network plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc authored and sparrc committed Dec 4, 2015
1 parent bcafadb commit 0d0a8e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ same type.
- [#364](https://github.com/influxdb/telegraf/pull/364): Support InfluxDB UDP output.
- [#370](https://github.com/influxdb/telegraf/pull/370): Support specifying multiple outputs, as lists.
- [#372](https://github.com/influxdb/telegraf/pull/372): Remove gosigar and update go-dockerclient for FreeBSD support. Thanks @MerlinDMC!
- [#382](https://github.com/influxdb/telegraf/pull/382): Add system wide network protocol stats to `net` plugin.

### Bugfixes
- [#331](https://github.com/influxdb/telegraf/pull/331): Dont overwrite host tag in redis plugin.
Expand Down
10 changes: 10 additions & 0 deletions plugins/system/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package system
import (
"fmt"
"net"
"strings"

"github.com/influxdb/telegraf/plugins"
)
Expand Down Expand Up @@ -79,6 +80,15 @@ func (s *NetIOStats) Gather(acc plugins.Accumulator) error {
acc.Add("drop_out", io.Dropout, tags)
}

// Get system wide stats for different network protocols
netprotos, err := s.ps.NetProto()
for _, proto := range netprotos {
for stat, value := range proto.Stats {
name := fmt.Sprintf("%s_%s", proto.Protocol, strings.ToLower(stat))
acc.Add(name, value, nil)
}
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions plugins/system/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type PS interface {
CPUTimes(perCPU, totalCPU bool) ([]cpu.CPUTimesStat, error)
DiskUsage() ([]*disk.DiskUsageStat, error)
NetIO() ([]net.NetIOCountersStat, error)
NetProto() ([]net.NetProtoCountersStat, error)
DiskIO() (map[string]disk.DiskIOCountersStat, error)
VMStat() (*mem.VirtualMemoryStat, error)
SwapStat() (*mem.SwapMemoryStat, error)
Expand Down Expand Up @@ -88,6 +89,10 @@ func (s *systemPS) DiskUsage() ([]*disk.DiskUsageStat, error) {
return usage, nil
}

func (s *systemPS) NetProto() ([]net.NetProtoCountersStat, error) {
return net.NetProtoCounters(nil)
}

func (s *systemPS) NetIO() ([]net.NetIOCountersStat, error) {
return net.NetIOCounters(true)
}
Expand Down

0 comments on commit 0d0a8e9

Please sign in to comment.