Skip to content

Commit

Permalink
Treat Bits as OctetString (prometheus#870)
Browse files Browse the repository at this point in the history
Signed-off-by: Sébastien Coavoux <[email protected]>
Signed-off-by: Stephan Windischmann <[email protected]>
  • Loading branch information
sebastien-coavoux authored and Stephan Windischmann committed Oct 27, 2023
1 parent 367b490 commit 5a181b7
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 5a181b7

Please sign in to comment.