Skip to content

Commit 9999e59

Browse files
Treat Bits as OctetString (#870)
Signed-off-by: Sébastien Coavoux <[email protected]>
1 parent b65f29c commit 9999e59

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
@@ -725,7 +725,7 @@ func pduValueAsString(pdu *gosnmp.SnmpPDU, typ string) string {
725725
// DisplayString.
726726
return pdu.Value.(string)
727727
case []byte:
728-
if typ == "" {
728+
if typ == "" || typ == "Bits" {
729729
typ = "OctetString"
730730
}
731731
// 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)