Skip to content

Commit eb1a0e3

Browse files
Treat Bits as OctetString
1 parent 87bf22c commit eb1a0e3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

collector/collector.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ func pduValueAsString(pdu *gosnmp.SnmpPDU, typ string) string {
621621
// DisplayString.
622622
return pdu.Value.(string)
623623
case []byte:
624-
if typ == "" {
624+
if typ == "" || typ == "Bits" {
625625
typ = "OctetString"
626626
}
627627
// Reuse the OID index parsing code.

collector/collector_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,11 @@ func TestPduValueAsString(t *testing.T) {
701701
typ: "InetAddressIPv6",
702702
result: "0102:0304:0506:0708:090A:0B0C:0D0E:0F10",
703703
},
704+
{
705+
pdu: &gosnmp.SnmpPDU{Value: []byte{2, 0}},
706+
typ: "Bits",
707+
result: "0x0200",
708+
},
704709
{
705710
pdu: &gosnmp.SnmpPDU{Value: nil},
706711
result: "",

0 commit comments

Comments
 (0)