Skip to content

Commit

Permalink
Add protocol stats to the network plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc committed Nov 19, 2015
1 parent a3feddd commit 50dc16b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugins/system/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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, 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 50dc16b

Please sign in to comment.