2

Facing a strange issue with the pysnmp agent return value. PYSNMP Agent receives the string format as "0a0a0a0a0a0a0a0a0a". In the MIB, OID is represented as HEXA STRING. When tried to return the string using rfc1902.OctetString(hexValue=str_temp), the output is blank because the hexavalue (0a0a0a) is decoded as new lines(\n) characters.

SNMPv2-SMI::example.154.12.1.0 = STRING: "

"

Pseudo code:

str="0a0a0a0a0a0a0a0a"
After Return using rfc1902.OctetString(str) or rfc1902.OctetString(hexaValue=str)

Excepted Output:

SNMPv2-SMI::example.154.12.1.0 = Hex-STRING: 0A 0A 0A 0A 0A 0A 0A 0A 

Can some one help me, how to decode or send the raw output to hexa string to get desired output as mentioned above.

user1720713
  • 184
  • 8
  • Doesn't it have a particular definition or a particular character in the MIB definition – Houda Jun 08 '20 at 08:00

1 Answers1

2
for oid, val in varBinds:
    print(oid.prettyPrint(),' = ',val.prettyPrint())
Houda
  • 671
  • 6
  • 16
  • Thanks for answering! A link to the docs and an explanation as to what PrettyPrinting is would improve this answer :) – Ari Cooper-Davis Jun 08 '20 at 07:32
  • I am looking for an answer that When SNMP agent sends the response as hexa value of 0a0a0a0a0a0a0a0a and the output showing is empty because of "\n" characters. How do i get the same hexa string output from PYSNMP agent – user1720713 Jun 09 '20 at 22:13