diff --git a/collector/collector.go b/collector/collector.go index 83438807..3c24f768 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -725,7 +725,7 @@ func pduValueAsString(pdu *gosnmp.SnmpPDU, typ string) string { // DisplayString. return pdu.Value.(string) case []byte: - if typ == "" { + if typ == "" || typ == "Bits" { typ = "OctetString" } // Reuse the OID index parsing code. diff --git a/collector/collector_test.go b/collector/collector_test.go index c4010cff..981f5d0d 100644 --- a/collector/collector_test.go +++ b/collector/collector_test.go @@ -701,6 +701,11 @@ func TestPduValueAsString(t *testing.T) { typ: "InetAddressIPv6", result: "0102:0304:0506:0708:090A:0B0C:0D0E:0F10", }, + { + pdu: &gosnmp.SnmpPDU{Value: []byte{2, 0}}, + typ: "Bits", + result: "0x0200", + }, { pdu: &gosnmp.SnmpPDU{Value: nil}, result: "",