Resolve gopsutil & unit test issues with net proto stats

This commit is contained in:
Cameron Sparr
2015-12-04 15:09:07 -07:00
parent 0d0a8e9b68
commit c83f220fc4
4 changed files with 43 additions and 9 deletions

View File

@@ -81,10 +81,12 @@ func (s *NetIOStats) Gather(acc plugins.Accumulator) error {
}
// Get system wide stats for different network protocols
netprotos, err := s.ps.NetProto()
// (ignore these stats if the call fails)
netprotos, _ := s.ps.NetProto()
for _, proto := range netprotos {
for stat, value := range proto.Stats {
name := fmt.Sprintf("%s_%s", proto.Protocol, strings.ToLower(stat))
name := fmt.Sprintf("%s_%s", strings.ToLower(proto.Protocol),
strings.ToLower(stat))
acc.Add(name, value, nil)
}
}