in pkg/systemstatsmonitor/net_collector.go [231:309]
func (nc *netCollector) recordNetDev() {
if nc.mNetDevRxBytes == nil {
return
}
if nc.mNetDevRxPackets == nil {
return
}
if nc.mNetDevRxErrors == nil {
return
}
if nc.mNetDevRxDropped == nil {
return
}
if nc.mNetDevRxFifo == nil {
return
}
if nc.mNetDevRxFrame == nil {
return
}
if nc.mNetDevRxCompressed == nil {
return
}
if nc.mNetDevRxMulticast == nil {
return
}
if nc.mNetDevTxBytes == nil {
return
}
if nc.mNetDevTxPackets == nil {
return
}
if nc.mNetDevTxErrors == nil {
return
}
if nc.mNetDevTxDropped == nil {
return
}
if nc.mNetDevTxFifo == nil {
return
}
if nc.mNetDevTxCollisions == nil {
return
}
if nc.mNetDevTxCarrier == nil {
return
}
if nc.mNetDevTxCompressed == nil {
return
}
fs, err := procfs.NewFS("/proc")
stats, err := fs.NetDev()
if err != nil {
glog.Errorf("Failed to retrieve net dev stat: %v", err)
return
}
for iface, ifaceStats := range stats {
tags := map[string]string{}
tags[interfaceNameLabel] = iface
nc.mNetDevRxBytes.Record(tags, int64(ifaceStats.RxBytes))
nc.mNetDevRxPackets.Record(tags, int64(ifaceStats.RxPackets))
nc.mNetDevRxErrors.Record(tags, int64(ifaceStats.RxErrors))
nc.mNetDevRxDropped.Record(tags, int64(ifaceStats.RxDropped))
nc.mNetDevRxFifo.Record(tags, int64(ifaceStats.RxFIFO))
nc.mNetDevRxFrame.Record(tags, int64(ifaceStats.RxFrame))
nc.mNetDevRxCompressed.Record(tags, int64(ifaceStats.RxCompressed))
nc.mNetDevRxMulticast.Record(tags, int64(ifaceStats.RxMulticast))
nc.mNetDevTxBytes.Record(tags, int64(ifaceStats.TxBytes))
nc.mNetDevTxPackets.Record(tags, int64(ifaceStats.TxPackets))
nc.mNetDevTxErrors.Record(tags, int64(ifaceStats.TxErrors))
nc.mNetDevTxDropped.Record(tags, int64(ifaceStats.TxDropped))
nc.mNetDevTxFifo.Record(tags, int64(ifaceStats.TxFIFO))
nc.mNetDevTxCollisions.Record(tags, int64(ifaceStats.TxCollisions))
nc.mNetDevTxCarrier.Record(tags, int64(ifaceStats.TxCarrier))
nc.mNetDevTxCompressed.Record(tags, int64(ifaceStats.TxCompressed))
}
}