From 04f5c0a247c30c9c3cbf54854e7bd28caac5c3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Coavoux?= Date: Thu, 30 Mar 2023 22:53:52 -0400 Subject: [PATCH] Treat Bits as OctetString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien Coavoux --- collector/collector.go | 2 +- collector/collector_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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: "",