Node.js的os module 提供了一系列跟操作系统相关的操作函数,比较简单,所以功能也就十分有限。我们可以去官网看各个函数的介绍:

  http://nodejs.org/api/os.html

 var os = require('os');

 console.log('the os tmpdir is: ' + os.tmpdir());
console.log('the endianness of this os is: ' + os.endianness());
console.log('the hostname of this os is: ' + os.hostname());
console.log('the type of this os is: ' + os.type());
console.log('the platform of this os is: ' + os.platform());
console.log('the arch of this os is: ' + os.arch());
console.log('the release of the os is: ' + os.release());
console.log('the uptime os the os is: ' + os.uptime()); console.log('the end of line of this os is: ' + os.EOL); //os.EOL:操作系统的换行符
console.log('................................................');
console.log('................................................');
showObj(os.cpus());
console.log('................................................');
console.log('................................................');
showObj(os.networkInterfaces());
console.log('................................................');
console.log('................................................');
showObj(os.loadavg()); function showObj(obj){
if (obj == null) {
console.log('error: ' + obj);
return false;
}
for (var key in obj) {
//key is a string, so we cannot use obj.key to replace obj[key] at here. For example, if name is a property of obj:
      //(obj.name is right, but obj."name" is wrong.)
      //(obj["name"] is right, but obj[name] is wrong.)
if (typeof(obj[key]) == 'array' || typeof(obj[key]) == 'object') {
showObj(obj[key]);
} else {
if (obj[key] != null)
console.log(key + "=" + obj[key]);
}
}
}

参考博客地址:http://blog.csdn.net/simpleiseasy/article/details/7253429

node.js 的 os 模块的更多相关文章

  1. Node.js:OS模块

    os模块,可以用来获取操作系统相关的信息和机器物理信息,例如操作系统平台,内核,cpu架构,内存,cpu,网卡等信息. 使用如下所示: const os = require('os'); var de ...

  2. 利用Node.js的Net模块实现一个命令行多人聊天室

    1.net模块基本API 要使用Node.js的net模块实现一个命令行聊天室,就必须先了解NET模块的API使用.NET模块API分为两大类:Server和Socket类.工厂方法. Server类 ...

  3. Node.js的Formidable模块的使用

    今天总结了下Node.js的Formidable模块的使用,下面做一些简要的说明. 1)     创建Formidable.IncomingForm对象 var form = new formidab ...

  4. Node.js入门:模块机制

    CommonJS规范      早在Netscape诞生不久后,JavaScript就一直在探索本地编程的路,Rhino是其代表产物.无奈那时服务端JavaScript走的路均是参考众多服务器端语言来 ...

  5. Node.js的net模块

    net模块提供了一个异步网络包装器,用于TCP网络编程,它包含了创建服务器和客户端的方法 创建TCP服务器 net.createServer方法 创建客户端去连接服务器 net.connect方法 简 ...

  6. node.js中express模块创建服务器和http模块客户端发请求

    首先下载express模块,命令行输入 npm install express 1.node.js中express模块创建服务端 在js代码同文件位置新建一个文件夹(www_root),里面存放网页文 ...

  7. node.js中ws模块创建服务端和客户端,网页WebSocket客户端

    首先下载websocket模块,命令行输入 npm install ws 1.node.js中ws模块创建服务端 // 加载node上websocket模块 ws; var ws = require( ...

  8. node.js中net模块创建服务器和客户端(TCP)

    node.js中net模块创建服务器和客户端 1.node.js中net模块创建服务器(net.createServer) // 将net模块 引入进来 var net = require(" ...

  9. 第5月第10天 node.js的request模块

    1.node.js的request模块 http://www.cnblogs.com/meteoric_cry/archive/2012/08/18/2645530.html

随机推荐

  1. Java关系操作符简写

    eq--等于.neq--不等于.lt--小于.lte--小于等于.gt--大于.gte--大于等于.empty.null

  2. hibernate 一对一关联关系 及其懒加载,总结

    一对一,则有主对象和从对象之区别 若无主对象,则从对象亦无存在之意义. 主对象为person 从对象为idcard <hibernate-mapping package="cn.itc ...

  3. 1119 网页布局,css写下拉列表

    <style type="text/css"> *{ margin:0px; padding:0px;} #body{ width:1000px; height:200 ...

  4. asp.net将内容导出到Excel,Table表格数据(html)导出EXCEL

    代码: /// <summary> /// HTML Table表格数据(html)导出EXCEL /// </summary> /// <param name=&quo ...

  5. [推荐]Bitnami 开源软件包安装解决方案

    [推荐]Bitnami 开源软件包安装解决方案 Bitnami is an app store for server software. Install your favorite applicati ...

  6. 用非管理员权限启动主程序,并用管理员权限启动子程序,导致WM_COPYDATA消息发送失败的问题

    问题描述 :     用非管理员权限启动dzh,dzh再启动dtssm,由于dtssm的配置文件app.manifest 中设置了requireAdministrator,导致dtssm总是以管理员权 ...

  7. Directx11教程(14) D3D11管线(2)

    下面我们来了解一些GPU memory的知识,主要参考资料:http://fgiesen.wordpress.com/0211/07/02/a-trip-through-the-graphics-pi ...

  8. linux上nginx+apache 搭建 svn服务器

    众所周知,nginx目前是不支持svn的,并且由于机房网络只开了80和22(ssh)端口,所以这时候就没法单独在服务器上搭建apache+svn .所以就产生了 nginx + apache + sv ...

  9. android获取本机的IP地址和mac物理地址

    /获取本机IP地址 public String getLocalIpAddress() { WifiManager wifiManager = (WifiManager) getSystemServi ...

  10. PayPal 高级工程总监:读完这 100 篇文献,就能成大数据高手

    原文地址 开源(Open Source)对大数据影响,有二:一方面,在大数据技术变革之路上,开源在众人之力和众人之智推动下,摧枯拉朽,吐故纳新,扮演着非常重要的推动作用:另一方面,开源也给大数据技术构 ...