0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 15:06:33 +01:00
nodejs/doc/api/os.markdown

132 lines
3.4 KiB
Markdown
Raw Normal View History

2012-02-27 20:09:34 +01:00
# os
Stability: 4 - API Frozen
2012-02-27 20:09:34 +01:00
Provides a few basic operating-system related utility functions.
2010-12-11 09:49:38 +01:00
Use `require('os')` to access this module.
2012-02-27 20:09:34 +01:00
## os.hostname()
2010-12-11 09:49:38 +01:00
Returns the hostname of the operating system.
2012-02-27 20:09:34 +01:00
## os.type()
Returns the operating system name.
2012-02-27 20:09:34 +01:00
## os.platform()
2011-04-27 05:02:54 +02:00
Returns the operating system platform.
2012-02-27 20:09:34 +01:00
## os.arch()
2011-04-27 05:02:54 +02:00
Returns the operating system CPU architecture.
2012-02-27 20:09:34 +01:00
## os.release()
Returns the operating system release.
2012-02-27 20:09:34 +01:00
## os.uptime()
Returns the system uptime in seconds.
2012-02-27 20:09:34 +01:00
## os.loadavg()
Returns an array containing the 1, 5, and 15 minute load averages.
2012-02-27 20:09:34 +01:00
## os.totalmem()
Returns the total amount of system memory in bytes.
2012-02-27 20:09:34 +01:00
## os.freemem()
Returns the amount of free system memory in bytes.
2012-02-27 20:09:34 +01:00
## os.cpus()
Returns an array of objects containing information about each CPU/core installed: model, speed (in MHz), and times (an object containing the number of CPU ticks spent in: user, nice, sys, idle, and irq).
Example inspection of os.cpus:
[ { model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times:
{ user: 252020,
nice: 0,
sys: 30340,
idle: 1070356870,
irq: 0 } },
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times:
{ user: 306960,
nice: 0,
sys: 26980,
idle: 1071569080,
irq: 0 } },
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times:
{ user: 248450,
nice: 0,
sys: 21750,
idle: 1070919370,
irq: 0 } },
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times:
{ user: 256880,
nice: 0,
sys: 19430,
idle: 1070905480,
irq: 20 } },
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times:
{ user: 511580,
nice: 20,
sys: 40900,
idle: 1070842510,
irq: 0 } },
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times:
{ user: 291660,
nice: 0,
sys: 34360,
idle: 1070888000,
irq: 10 } },
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times:
{ user: 308260,
nice: 0,
sys: 55410,
idle: 1071129970,
irq: 880 } },
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times:
{ user: 266450,
nice: 1480,
sys: 34920,
idle: 1072572010,
2011-03-17 00:31:38 +01:00
irq: 30 } } ]
2012-02-27 20:09:34 +01:00
## os.networkInterfaces()
2011-03-17 00:31:38 +01:00
Get a list of network interfaces:
{ lo0:
[ { address: '::1', family: 'IPv6', internal: true },
{ address: 'fe80::1', family: 'IPv6', internal: true },
{ address: '127.0.0.1', family: 'IPv4', internal: true } ],
en1:
[ { address: 'fe80::cabc:c8ff:feef:f996', family: 'IPv6',
internal: false },
{ address: '10.0.1.123', family: 'IPv4', internal: false } ],
vmnet1: [ { address: '10.99.99.254', family: 'IPv4', internal: false } ],
vmnet8: [ { address: '10.88.88.1', family: 'IPv4', internal: false } ],
ppp0: [ { address: '10.2.0.231', family: 'IPv4', internal: false } ] }
2011-03-17 00:31:38 +01:00