What is a good way to show floating point number through SNMP?

I am encoding an SNMP agent. I need to send decimal point values ​​to SNMP manager.

I have a few options:

  • Truncate a number.
  • Multiply a constant.
  • Request a storage package.

If I truncate a number, I lose a lot of the information I need.

If I multiply by a constant, then the manager will display strange units that the end user probably will not see. (grams instead of kilograms).

So I'm doing option 3. What should I do?

+7
floating-point snmp
source share
3 answers

The usual standard way is to define a TEXTUAL CONVENTION with an integral type (for example, Integer32 or Unsigned32) and DISPLAY-HINT with the format "dN", where N is the number of places where the decimal number should be shifted to display.

Thus, for a value with one decimal place from (say) from 0.0 to 10.0, you should use the TEXTUAL CONVENTION of type Unsigned32 (0..100) and DISPLAY-HINT "d-1". On the conductor, the value changes from 0 to 100, but the manager (through the downloadable MIB module) shifts the decimal one place to display the range from 0.0 to 10.0.

Other ways to do this do not contribute to interoperability.

+11
source share

as octect stream in IEEE-754 format (8 octets). See: http://en.wikipedia.org/wiki/IEEE_754-2008

+2
source share

I would rather send this data through OCTET STRING / DisplayString. Rooms such as "1.5" can be sent easily.

However, if the data needs to be accurate, you can use Kyle's sentence by sending bytes (octets). It is noticeable that it is also dispatched via OCTET STRING, as it is an ideal byte container.

+1
source share

All Articles