On Jan 16, 8:26 am, jackster the jackle <cont... / thirdorder.net>
wrote:
> Hi Ruby Forum,
>
> I have a script that opens a UDPSocket on port 162 and listens for traps
> which are then sent to STDOUT for now.
>
> I am seeing data strings coming in that are in a format that I need to
> decode somehow. I have read through all the doco on UDPSocket and
> BasicSocket and Socket and don't see any way to decode the data being
> sent in the traps.
>
> Here is an example of what I'm seeing from my Cisco devices:
>
> ["0\201\351\002\001\000\004\02087", ["AF_INET", 51709, "10.1.1.1",
> "10.1.1.1"]]
>
> The first numbers enclosed in the first set of parenthesis contain the
> data in the trap.
>
> Does anyone know how I would go about decoding these?
>
> Thanks in advance
>
> jackster.mobi
> --
> Posted viahttp://www.ruby-forum.com/.

I'm not sure, but the data format is probably dependent on the Cisco
devices. I would check their documentation for more info.

You might also want to check out Ruby SNMP - http://snmplib.rubyforge.org/
- rather than writing your own socket routines.