Skip to content
Browse files

Fix parsing of high resolution timestamps

  • Loading branch information...
1 parent 68d68ad commit 84422c79694ad5ed2cefaa5f27f3c8d0dde8d495 @tmm1 tmm1 committed Aug 2, 2011
Showing with 7 additions and 2 deletions.
  1. +1 −1 lib/collectd.js
  2. +6 −1 src/collectd.coffee
View
2 lib/collectd.js
@@ -107,7 +107,7 @@
_ref = jspack.Unpack("!LL", buf), upper = _ref[0], lower = _ref[1];
return {
type: ptype,
- value: (upper << 2) + (lower >> 30)
+ value: (upper << 2) + ((lower >> 30) & 0x3)
};
};
decode_network_number = function(ptype, plen, buf) {
View
7 src/collectd.coffee
@@ -96,9 +96,14 @@ decode_network_values = (ptype, plen, buf) ->
value: (_decode_network_values ptype, plen, buf)
decode_network_time = (ptype, plen, buf) ->
+ # cdtime_t is (seconds << 30)
+ #
+ # Ideally we would read a 64bit int and >>30, but javascript
+ # can't do that. So we read the upper 32bits, move it over and add
+ # the remaining 2 bits for the 34bit time in seconds.
[upper, lower] = jspack.Unpack("!LL", buf)
type: ptype
- value: (upper << 2) + (lower >> 30)
+ value: (upper << 2) + ((lower >> 30) & 0x3)
decode_network_number = (ptype, plen, buf) ->
type: ptype

0 comments on commit 84422c7

Please sign in to comment.
Something went wrong with that request. Please try again.