Skip to content

os.uptime() may return fractional seconds #15

@thom-nic

Description

@thom-nic

https://github.com/VoltServer/node-snmpjs/blob/develop/lib/mib/mib-2/system.js#L38

Ensure timeticks will always be an integer. Apparently it is not guaranteed that os.uptime() will always be a whole number. But this is platform (maybe node runtime?) dependent.

Re: nodejs/node#41636

This has been observed on arm32v7 Linux.

No fraction:

volt@voltserv-4209 ~
$ cat /etc/os-release  
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

volt@voltserv-4209 ~
$ node --version
v14.16.1

volt@voltserv-4209 ~
$ node
Welcome to Node.js v14.16.1.
Type ".help" for more information.
> os.uptime()
533791
> 

Fraction:

volt@voltserv-1be5 ~
$ /usr/local/bin/node --version
v14.18.2

volt@voltserv-1be5 ~
$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

volt@voltserv-1be5 ~
$ node
Welcome to Node.js v14.18.2.
Type ".help" for more information.
> os.uptime()
14204.11
> 

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions