Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Counter64 stringified as '[object Object'] when serialized #22

Closed
infrared opened this issue Feb 20, 2014 · 1 comment
Closed

Counter64 stringified as '[object Object'] when serialized #22

infrared opened this issue Feb 20, 2014 · 1 comment

Comments

@infrared
Copy link

From one of my traps, one of the varbinds had a string_value as '[object Object]'

 { oid: '1.3.6.1.4.1.9.9.383.1.1.1.0',
      typename: 'Counter64',
      value: { lo: 2974423586, hi: 1588 },
      string_value: '[object Object]' },

From the tcpdump:

   .1.3.6.1.4.1.9.9.383.1.1.1.0=1355944442194980864.000771

Please let me know what other information I can provide to assist.

ghost pushed a commit that referenced this issue Feb 22, 2014
@ghost
Copy link

ghost commented Feb 22, 2014

This requires the analogue of sprintf("%llu", (uint64_t)whatever) without having access to any integer operations capable of supporting more than 32-bit quantities. Remarkably, this seems like an unsolved problem in the Node.js ecosystem, at least without going native. node-int64 stringifies anything that uses more than 53 bits as 'Infinity', which is really unhelpful. int64-native would work here but I'd rather not introduce that dependency if we can avoid it, so I implemented the necessary pieces for 64-bit integer decoding in Javascript.
With this change, I now do:

# snmptrap -v 2c -c public localhost trapoid 1.3.6.1.4.1.9926.1.21.1.7.3 1.3.6.1.4.1.9926.1.21.1.4.1.1.14 i 2 1.3.6.1.4.1.9926.1.21.1.4.1.1.10 C 2394872985723948

and get

…
        { oid: '1.3.6.1.4.1.9926.1.21.1.4.1.1.10',
          typename: 'Counter64',
          value: { _hi: 557599, _lo: 3516441644 },
          string_value: '2394872985723948' } ] } }

Test cases added, 0.1.6 released as well. Thanks for the report, though I must say that I did not expect this simple issue to require this much work!

@ghost ghost closed this as completed Feb 22, 2014
@ghost ghost self-assigned this Feb 22, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant