{ "source": "doc/api/os.md", "modules": [ { "textRaw": "OS", "name": "os", "stability": 2, "stabilityText": "Stable", "desc": "

Provides a few basic operating-system related utility functions.\n\n

\n

Use require('os') to access this module.\n\n

\n", "properties": [ { "textRaw": "os.EOL", "name": "EOL", "desc": "

A constant defining the appropriate End-of-line marker for the operating\nsystem.\n\n

\n" } ], "methods": [ { "textRaw": "os.arch()", "type": "method", "name": "arch", "desc": "

Returns the operating system CPU architecture. Possible values are 'x64',\n'arm' and 'ia32'. Returns the value of [process.arch][].\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.cpus()", "type": "method", "name": "cpus", "desc": "

Returns an array of objects containing information about each CPU/core\ninstalled: model, speed (in MHz), and times (an object containing the number of\nmilliseconds the CPU/core spent in: user, nice, sys, idle, and irq).\n\n

\n

Example inspection of os.cpus:\n\n

\n
[ { model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',\n    speed: 2926,\n    times:\n     { user: 252020,\n       nice: 0,\n       sys: 30340,\n       idle: 1070356870,\n       irq: 0 } },\n  { model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',\n    speed: 2926,\n    times:\n     { user: 306960,\n       nice: 0,\n       sys: 26980,\n       idle: 1071569080,\n       irq: 0 } },\n  { model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',\n    speed: 2926,\n    times:\n     { user: 248450,\n       nice: 0,\n       sys: 21750,\n       idle: 1070919370,\n       irq: 0 } },\n  { model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',\n    speed: 2926,\n    times:\n     { user: 256880,\n       nice: 0,\n       sys: 19430,\n       idle: 1070905480,\n       irq: 20 } },\n  { model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',\n    speed: 2926,\n    times:\n     { user: 511580,\n       nice: 20,\n       sys: 40900,\n       idle: 1070842510,\n       irq: 0 } },\n  { model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',\n    speed: 2926,\n    times:\n     { user: 291660,\n       nice: 0,\n       sys: 34360,\n       idle: 1070888000,\n       irq: 10 } },\n  { model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',\n    speed: 2926,\n    times:\n     { user: 308260,\n       nice: 0,\n       sys: 55410,\n       idle: 1071129970,\n       irq: 880 } },\n  { model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',\n    speed: 2926,\n    times:\n     { user: 266450,\n       nice: 1480,\n       sys: 34920,\n       idle: 1072572010,\n       irq: 30 } } ]
\n

Note that since nice values are UNIX centric in Windows the nice values of\nall processors are always 0.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.endianness()", "type": "method", "name": "endianness", "desc": "

Returns the endianness of the CPU. Possible values are 'BE' for big endian\nor 'LE' for little endian.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.freemem()", "type": "method", "name": "freemem", "desc": "

Returns the amount of free system memory in bytes.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.homedir()", "type": "method", "name": "homedir", "desc": "

Returns the home directory of the current user.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.hostname()", "type": "method", "name": "hostname", "desc": "

Returns the hostname of the operating system.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.loadavg()", "type": "method", "name": "loadavg", "desc": "

Returns an array containing the 1, 5, and 15 minute load averages.\n\n

\n

The load average is a measure of system activity, calculated by the operating\nsystem and expressed as a fractional number. As a rule of thumb, the load\naverage should ideally be less than the number of logical CPUs in the system.\n\n

\n

The load average is a very UNIX-y concept; there is no real equivalent on\nWindows platforms. That is why this function always returns [0, 0, 0] on\nWindows.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.networkInterfaces()", "type": "method", "name": "networkInterfaces", "desc": "

Get a list of network interfaces:\n\n

\n
{ lo:\n   [ { address: '127.0.0.1',\n       netmask: '255.0.0.0',\n       family: 'IPv4',\n       mac: '00:00:00:00:00:00',\n       internal: true },\n     { address: '::1',\n       netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',\n       family: 'IPv6',\n       mac: '00:00:00:00:00:00',\n       internal: true } ],\n  eth0:\n   [ { address: '192.168.1.108',\n       netmask: '255.255.255.0',\n       family: 'IPv4',\n       mac: '01:02:03:0a:0b:0c',\n       internal: false },\n     { address: 'fe80::a00:27ff:fe4e:66a1',\n       netmask: 'ffff:ffff:ffff:ffff::',\n       family: 'IPv6',\n       mac: '01:02:03:0a:0b:0c',\n       internal: false } ] }
\n

Note that due to the underlying implementation this will only return network\ninterfaces that have been assigned an address.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.platform()", "type": "method", "name": "platform", "desc": "

Returns the operating system platform. Possible values are 'darwin',\n'freebsd', 'linux', 'sunos' or 'win32'. Returns the value of\n[process.platform][].\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.release()", "type": "method", "name": "release", "desc": "

Returns the operating system release.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.tmpdir()", "type": "method", "name": "tmpdir", "desc": "

Returns the operating system's default directory for temporary files.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.totalmem()", "type": "method", "name": "totalmem", "desc": "

Returns the total amount of system memory in bytes.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.type()", "type": "method", "name": "type", "desc": "

Returns the operating system name. For example 'Linux' on Linux, 'Darwin'\non OS X and 'Windows_NT' on Windows.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.uptime()", "type": "method", "name": "uptime", "desc": "

Returns the system uptime in seconds.\n\n

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "os.userInfo([options])", "type": "method", "name": "userInfo", "signatures": [ { "params": [ { "textRaw": "`options` {Object} ", "options": [ { "textRaw": "`encoding` {String} Character encoding used to interpret resulting strings. If `encoding` is set to `'buffer'`, the `username`, `shell`, and `homedir` values will be `Buffer` instances. (Default: 'utf8') ", "name": "encoding", "default": "utf8", "type": "String", "desc": "Character encoding used to interpret resulting strings. If `encoding` is set to `'buffer'`, the `username`, `shell`, and `homedir` values will be `Buffer` instances." } ], "name": "options", "type": "Object", "optional": true } ] }, { "params": [ { "name": "options", "optional": true } ] } ], "desc": "

Returns a subset of the password file entry for the current effective user. The\nreturned object includes the username, uid, gid, shell, and homedir.\nOn Windows, the uid and gid fields are -1, and shell is null.\n\n

\n

The value of homedir returned by userInfo() comes directly from the\noperating system. This differs from the result of os.homedir(), which queries\nseveral environment variables for the home directory before falling back to the\noperating system response.\n\n

\n" } ], "type": "module", "displayName": "OS" } ] }