node.js 的 os 模块
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 模块的更多相关文章
- Node.js:OS模块
os模块,可以用来获取操作系统相关的信息和机器物理信息,例如操作系统平台,内核,cpu架构,内存,cpu,网卡等信息. 使用如下所示: const os = require('os'); var de ...
- 利用Node.js的Net模块实现一个命令行多人聊天室
1.net模块基本API 要使用Node.js的net模块实现一个命令行聊天室,就必须先了解NET模块的API使用.NET模块API分为两大类:Server和Socket类.工厂方法. Server类 ...
- Node.js的Formidable模块的使用
今天总结了下Node.js的Formidable模块的使用,下面做一些简要的说明. 1) 创建Formidable.IncomingForm对象 var form = new formidab ...
- Node.js入门:模块机制
CommonJS规范 早在Netscape诞生不久后,JavaScript就一直在探索本地编程的路,Rhino是其代表产物.无奈那时服务端JavaScript走的路均是参考众多服务器端语言来 ...
- Node.js的net模块
net模块提供了一个异步网络包装器,用于TCP网络编程,它包含了创建服务器和客户端的方法 创建TCP服务器 net.createServer方法 创建客户端去连接服务器 net.connect方法 简 ...
- node.js中express模块创建服务器和http模块客户端发请求
首先下载express模块,命令行输入 npm install express 1.node.js中express模块创建服务端 在js代码同文件位置新建一个文件夹(www_root),里面存放网页文 ...
- node.js中ws模块创建服务端和客户端,网页WebSocket客户端
首先下载websocket模块,命令行输入 npm install ws 1.node.js中ws模块创建服务端 // 加载node上websocket模块 ws; var ws = require( ...
- node.js中net模块创建服务器和客户端(TCP)
node.js中net模块创建服务器和客户端 1.node.js中net模块创建服务器(net.createServer) // 将net模块 引入进来 var net = require(" ...
- 第5月第10天 node.js的request模块
1.node.js的request模块 http://www.cnblogs.com/meteoric_cry/archive/2012/08/18/2645530.html
随机推荐
- DataGridView绑定复杂实体(属性本身又是实体)
今天我们来讨论下一个实体中某个属性又是实体的类型的集合绑定到DataGridView上的问题. 先来写一个Student类 public class Student { public int Stud ...
- css3多列显示
columen-width:定义单列显示的宽度.初始值是auto,适用于不可替代的块级元素,行内块元素和单元格,表格元素除外. 目前Webkit引擎支持-webkit-column-width,Moz ...
- jQuery页面滚动监听事件及高级效果插件
jQuery页面滚动监听事件及高级效果插件 1. One Page scroll (只适用于上下焦点图)http://www.thepetedesign.com/demos/onepage_scrol ...
- Android图片处理-图片压缩处理
这里先重复温习一下上一篇,调用相册获取图片: /*** * 这个是调用android内置的intent,来过滤图片文件 ,同时也可以过滤其他的 */ Intent intent = new Inten ...
- [苏飞开发助手V1.0测试版]官方教程与升级报告
[苏飞开发助手V1.0测试版]官方教程与升级报告导读部分----------------------------------------------------------------- ...
- VS2015 ASP.NET5 Web项目结构浅析
前言 本文个人同步博客地址http://aehyok.com/Blog/Detail/76.html 个人网站地址:aehyok.com QQ 技术群号:206058845,验证码为:aehyok 本 ...
- JavaScript中如何中断forEach循环
先来看下forEach的实现 // Production steps of ECMA-262, Edition 5, 15.4.4.18// Reference: http://es5.github. ...
- 使用RAML描述API文档信息的一些用法整理
RAML是Restful API Modeling Language的缩写,是用来描述API信息的文档. 创建一个.raml后缀的文件,用Atom打开. 基本用法 #%RAML 0.8 title: ...
- URLEncode与URLDecode总结与实现
URLEncode: 用于编码URL字符串,数字和字母保持不变,空格变为'+',其他(如:中文字符)先转换为十六进制表示,然后在每个字节前面加一个标识符%,例如:“啊”字 Ascii的十六进制是0xB ...
- css3动画特效:纯css3制作win8加载动画特效
Windows 8 完整效果如上图:这个里面可能是css冲突,喜欢的可以自己去体征一下: css特效代码: <style type="text/css"> ...