Skip to content

Commit

Permalink
system: floor os.uptime() result to ensure it is always an integer
Browse files Browse the repository at this point in the history
- Fixes #15
  • Loading branch information
thom-nic committed Mar 25, 2022
1 parent 1051eaa commit b38e57b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/mib/mib-2/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ mib2_system_sysObjectID(oid, prq)
function
mib2_system_sysUpTime(prq)
{
var uptime = os.uptime() * 100; // uptime returns seconds, TimeTicks specifies 100ths of a second.
// NOTE: on some platforms, os.uptime() may return a float! This was observed on node v16.13.1 armv7
// See: https://github.com/nodejs/node/issues/41636
var uptime = Math.floor(os.uptime() * 100); // uptime returns seconds, TimeTicks specifies 100ths of a second.
var val = snmp.data.createData({ type: 'TimeTicks', value: uptime });
snmp.provider.readOnlyScalar(prq, val);
}
Expand Down

0 comments on commit b38e57b

Please sign in to comment.