TECHZEN Zenoss User Community ARCHIVE  

SNMP Hex String - Not a string really?

Subject: SNMP Hex String - Not a string really?
Author: [Not Specified]
Posted: 2015-04-28 13:07

Curious, saw an old post that was never answered: http://community.zenoss.org/message/16279

I saw the same issue with an SNMP modeler where the hex string doesn't appear to convert correctly.

(Pdb) pp the_system_mac
"\x08\x00'||\xde"

(Pdb) type(the_system_mac)

The only way to convert this to a valid ASCII string is to use binascii.

(Pdb) import binascii
(Pdb) formatted_system_mac=binascii.hexlify(the_system_mac)
(Pdb) print formatted_system_mac
0800277c7cde #< Correct format of MAC address

(Pdb) type(formatted_system_mac)

Is there a cleaner way to do this within a modeler script Or is using binascii.hexlify the best option

This is my first Zenpack, so hoping someone more experienced could shed more light if there is a better approach.

Thanks

-J



< Previous
AWS Zenpack via a webproxy with Data protection
  Next
Windows Event Log collection
>