Make a compromise: Use Rx.Packets and Tx.Packets if the *Unicast.Packets is empty. Add a comment in the code to explain why
This commit is contained in:
@ -294,7 +294,12 @@ func (m *InterfaceMIB) addIfEntry(iface *api.InterfaceCounters, idx int) {
|
||||
// ifInUcastPkts (.11)
|
||||
item = m.handler.Add(fmt.Sprintf("%s.11.%d", ifEntryOID, idx))
|
||||
item.Type = pdu.VariableTypeCounter32
|
||||
// iface.Rx*cast.Packets is only set if "set interface feature X stats-collect-rx arc device-input" is configured
|
||||
if iface.RxUnicast.Packets == 0 {
|
||||
item.Value = uint32(iface.Rx.Packets)
|
||||
} else {
|
||||
item.Value = uint32(iface.RxUnicast.Packets)
|
||||
}
|
||||
|
||||
// ifInNUcastPkts (.12) - multicast + broadcast
|
||||
item = m.handler.Add(fmt.Sprintf("%s.12.%d", ifEntryOID, idx))
|
||||
@ -324,7 +329,12 @@ func (m *InterfaceMIB) addIfEntry(iface *api.InterfaceCounters, idx int) {
|
||||
// ifOutUcastPkts (.17)
|
||||
item = m.handler.Add(fmt.Sprintf("%s.17.%d", ifEntryOID, idx))
|
||||
item.Type = pdu.VariableTypeCounter32
|
||||
// iface.Tx*cast.Packets is only set if "set interface feature X stats-collect-tx arc interface-output" is configured
|
||||
if iface.TxUnicast.Packets == 0 {
|
||||
item.Value = uint32(iface.Tx.Packets)
|
||||
} else {
|
||||
item.Value = uint32(iface.TxUnicast.Packets)
|
||||
}
|
||||
|
||||
// ifOutNUcastPkts (.18) - multicast + broadcast
|
||||
item = m.handler.Add(fmt.Sprintf("%s.18.%d", ifEntryOID, idx))
|
||||
@ -385,7 +395,11 @@ func (m *InterfaceMIB) addIfXTable(iface *api.InterfaceCounters, idx int) {
|
||||
// ifHCInUcastPkts (.7)
|
||||
item = m.handler.Add(fmt.Sprintf("%s.7.%d", ifXTableOID, idx))
|
||||
item.Type = pdu.VariableTypeCounter64
|
||||
if iface.RxUnicast.Packets == 0 {
|
||||
item.Value = iface.Rx.Packets
|
||||
} else {
|
||||
item.Value = iface.RxUnicast.Packets
|
||||
}
|
||||
|
||||
// ifHCInMulticastPkts (.8)
|
||||
item = m.handler.Add(fmt.Sprintf("%s.8.%d", ifXTableOID, idx))
|
||||
@ -405,7 +419,11 @@ func (m *InterfaceMIB) addIfXTable(iface *api.InterfaceCounters, idx int) {
|
||||
// ifHCOutUcastPkts (.11)
|
||||
item = m.handler.Add(fmt.Sprintf("%s.11.%d", ifXTableOID, idx))
|
||||
item.Type = pdu.VariableTypeCounter64
|
||||
if iface.TxUnicast.Packets == 0 {
|
||||
item.Value = iface.Tx.Packets
|
||||
} else {
|
||||
item.Value = iface.TxUnicast.Packets
|
||||
}
|
||||
|
||||
// ifHCOutMulticastPkts (.12)
|
||||
item = m.handler.Add(fmt.Sprintf("%s.12.%d", ifXTableOID, idx))
|
||||
|
Reference in New Issue
Block a user