Add network protocol stats to the network plugin
This commit is contained in:
committed by
Cameron Sparr
parent
bcafadb68a
commit
0d0a8e9b68
@@ -3,6 +3,7 @@ package system
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/influxdb/telegraf/plugins"
|
||||
)
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user