Skip to content

Commit

Permalink
Treat Bits as OctetString (#870)
Browse files Browse the repository at this point in the history
Signed-off-by: Sébastien Coavoux <[email protected]>
  • Loading branch information
sebastien-coavoux authored May 2, 2023
1 parent b65f29c commit 9999e59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down

0 comments on commit 9999e59

Please sign in to comment.