5
<title>os Node.js v0.6.18 Manual & Documentation</title>
6
<link rel="stylesheet" href="assets/style.css">
7
<link rel="stylesheet" href="assets/sh.css">
8
<link rel="canonical" href="http://nodejs.org/api/os.html">
10
<body class="alt apidoc" id="api-section-os">
11
<div id="intro" class="interior">
12
<a href="/" title="Go back to the home page">
13
<img id="logo" src="http://nodejs.org/images/logo-light.png" alt="node.js">
16
<div id="content" class="clearfix">
17
<div id="column2" class="interior">
19
<li><a href="/" class="home">Home</a></li>
20
<li><a href="/#download" class="download">Download</a></li>
21
<li><a href="/about/" class="about">About</a></li>
22
<li><a href="http://search.npmjs.org/" class="npm">npm Registry</a></li>
23
<li><a href="http://nodejs.org/api/" class="docs current">Docs</a></li>
24
<li><a href="http://blog.nodejs.org" class="blog">Blog</a></li>
25
<li><a href="/community/" class="community">Community</a></li>
26
<li><a href="/logos/" class="logos">Logos</a></li>
27
<li><a href="http://jobs.nodejs.org/" class="jobs">Jobs</a></li>
29
<p class="twitter"><a href="http://twitter.com/nodejs">@nodejs</a></p>
32
<div id="column1" class="interior">
34
<h1>Node.js v0.6.18 Manual & Documentation</h1>
37
<a href="index.html" name="toc">Index</a> |
38
<a href="all.html">View on single page</a> |
39
<a href="os.json">View as JSON</a>
46
<h2>Table of Contents</h2>
48
<li><a href="#os_os">os</a><ul>
49
<li><a href="#os_os_hostname">os.hostname()</a></li>
50
<li><a href="#os_os_type">os.type()</a></li>
51
<li><a href="#os_os_platform">os.platform()</a></li>
52
<li><a href="#os_os_arch">os.arch()</a></li>
53
<li><a href="#os_os_release">os.release()</a></li>
54
<li><a href="#os_os_uptime">os.uptime()</a></li>
55
<li><a href="#os_os_loadavg">os.loadavg()</a></li>
56
<li><a href="#os_os_totalmem">os.totalmem()</a></li>
57
<li><a href="#os_os_freemem">os.freemem()</a></li>
58
<li><a href="#os_os_cpus">os.cpus()</a></li>
59
<li><a href="#os_os_networkinterfaces">os.networkInterfaces()</a></li>
67
<h1>os<span><a class="mark" href="#os_os" id="os_os">#</a></span></h1>
68
<pre><code>Stability: 4 - API Frozen</code></pre>
69
<p>Provides a few basic operating-system related utility functions.
72
<p>Use <code>require('os')</code> to access this module.
75
<h2>os.hostname()<span><a class="mark" href="#os_os_hostname" id="os_os_hostname">#</a></span></h2>
76
<p>Returns the hostname of the operating system.
79
<h2>os.type()<span><a class="mark" href="#os_os_type" id="os_os_type">#</a></span></h2>
80
<p>Returns the operating system name.
83
<h2>os.platform()<span><a class="mark" href="#os_os_platform" id="os_os_platform">#</a></span></h2>
84
<p>Returns the operating system platform.
87
<h2>os.arch()<span><a class="mark" href="#os_os_arch" id="os_os_arch">#</a></span></h2>
88
<p>Returns the operating system CPU architecture.
91
<h2>os.release()<span><a class="mark" href="#os_os_release" id="os_os_release">#</a></span></h2>
92
<p>Returns the operating system release.
95
<h2>os.uptime()<span><a class="mark" href="#os_os_uptime" id="os_os_uptime">#</a></span></h2>
96
<p>Returns the system uptime in seconds.
99
<h2>os.loadavg()<span><a class="mark" href="#os_os_loadavg" id="os_os_loadavg">#</a></span></h2>
100
<p>Returns an array containing the 1, 5, and 15 minute load averages.
103
<h2>os.totalmem()<span><a class="mark" href="#os_os_totalmem" id="os_os_totalmem">#</a></span></h2>
104
<p>Returns the total amount of system memory in bytes.
107
<h2>os.freemem()<span><a class="mark" href="#os_os_freemem" id="os_os_freemem">#</a></span></h2>
108
<p>Returns the amount of free system memory in bytes.
111
<h2>os.cpus()<span><a class="mark" href="#os_os_cpus" id="os_os_cpus">#</a></span></h2>
112
<p>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).
115
<p>Example inspection of os.cpus:
118
<pre><code>[ { model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
126
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
134
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
142
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
150
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
158
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
166
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
174
{ model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
181
irq: 30 } } ]</code></pre>
182
<h2>os.networkInterfaces()<span><a class="mark" href="#os_os_networkinterfaces" id="os_os_networkinterfaces">#</a></span></h2>
183
<p>Get a list of network interfaces:
187
[ { address: '::1', family: 'IPv6', internal: true },
188
{ address: 'fe80::1', family: 'IPv6', internal: true },
189
{ address: '127.0.0.1', family: 'IPv4', internal: true } ],
191
[ { address: 'fe80::cabc:c8ff:feef:f996', family: 'IPv6',
193
{ address: '10.0.1.123', family: 'IPv4', internal: false } ],
194
vmnet1: [ { address: '10.99.99.254', family: 'IPv4', internal: false } ],
195
vmnet8: [ { address: '10.88.88.1', family: 'IPv4', internal: false } ],
196
ppp0: [ { address: '10.2.0.231', family: 'IPv4', internal: false } ] }</code></pre>
202
<ul class="clearfix">
203
<li><a href="/">Node.js</a></li>
204
<li><a href="/#download">Download</a></li>
205
<li><a href="/about/">About</a></li>
206
<li><a href="http://search.npmjs.org/">npm Registry</a></li>
207
<li><a href="http://nodejs.org/api/">Docs</a></li>
208
<li><a href="http://blog.nodejs.org">Blog</a></li>
209
<li><a href="/community/">Community</a></li>
210
<li><a href="/logos/">Logos</a></li>
211
<li><a href="http://jobs.nodejs.org/">Jobs</a></li>
212
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
215
<p>Copyright <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.6.18/LICENSE">license</a>.</p>
218
<script src="../sh_main.js"></script>
219
<script src="../sh_javascript.min.js"></script>
220
<script>highlight(undefined, undefined, 'pre');</script>
222
var gaJsHost = (("https:" == document.location.protocol) ?
223
"https://ssl." : "http://www.");
224
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
228
var pageTracker = _gat._getTracker("UA-10874194-2");
229
pageTracker._trackPageview();
230
} catch(err) {}</script>