zoukankan      html  css  js  c++  java
  • 36.Node.js 工具模块--OS模块系统操作

    转自:http://www.runoob.com/nodejs/nodejs-module-system.html

    Node.js os 模块提供了一些基本的系统操作函数。我们可以通过以下方式引入该模块:

    var os = require("os")

    方法

    序号方法 & 描述
    1 os.tmpdir()
    返回操作系统的默认临时文件夹。
    2 os.endianness()
    返回 CPU 的字节序,可能的是 "BE" 或 "LE"。
    3 os.hostname()
    返回操作系统的主机名。
    4 os.type()
    返回操作系统名
    5 os.platform()
    返回操作系统名
    6 os.arch()
    返回操作系统 CPU 架构,可能的值有 "x64"、"arm" 和 "ia32"。
    7 os.release()
    返回操作系统的发行版本。
    8 os.uptime()
    返回操作系统运行的时间,以秒为单位。
    9 os.loadavg()
    返回一个包含 1、5、15 分钟平均负载的数组。
    10 os.totalmem()
    返回系统内存总量,单位为字节。
    11 os.freemem()
    返回操作系统空闲内存量,单位是字节。
    12 os.cpus()
    返回一个对象数组,包含所安装的每个 CPU/内核的信息:型号、速度(单位 MHz)、时间(一个包含 user、nice、sys、idle 和 irq 所使用 CPU/内核毫秒数的对象)。
    13 os.networkInterfaces()
    获得网络接口列表。

    属性

    序号属性 & 描述
    1 os.EOL
    定义了操作系统的行尾符的常量。

    实例

    创建 main.js 文件,代码如下所示:

    var os = require("os");
    
    // CPU 的字节序
    console.log('endianness : ' + os.endianness());
    
    // 操作系统名
    console.log('type : ' + os.type());
    
    // 操作系统名
    console.log('platform : ' + os.platform());
    
    // 系统内存总量
    console.log('total memory : ' + os.totalmem() + " bytes.");
    
    // 操作系统空闲内存量
    console.log('free memory : ' + os.freemem() + " bytes.");

    代码执行结果如下:

    $ node main.js 
    endianness : LE
    type : Linux
    platform : linux
    total memory : 25103400960 bytes.
    free memory : 20676710400 bytes.
  • 相关阅读:
    “人工智能”前景:只有人工,没有智能
    google scholar vs baidu scholar-what is your problem
    springSecurity使用
    springMVC中的HttpSession与Model
    mybatis关于Criteria的一点小坑。。。
    MyBatis的Mapper接口以及Example的实例函数及详解
    被springSecurity坑哭的一天
    Mybatis-Generator
    Redis五种数据类型应用场景
    springboot_自动配置原理
  • 原文地址:https://www.cnblogs.com/sharpest/p/8058332.html
Copyright © 2011-2022 走看看