zoukankan      html  css  js  c++  java
  • node.js 的 os 模块

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

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

     2 var os = require('os');
     3 
     4 console.log('the os tmpdir is: ' + os.tmpdir());
     5 console.log('the endianness of this os is: ' + os.endianness());
     6 console.log('the hostname of this os is: ' + os.hostname());
     7 console.log('the type of this os is: ' + os.type());
     8 console.log('the platform of this os is: ' + os.platform());
     9 console.log('the arch of this os is: ' + os.arch());
    10 console.log('the release of the os is: ' + os.release());
    11 console.log('the uptime os the os is: ' + os.uptime());
    12 
    13 
    14 console.log('the end of line of this os is: ' + os.EOL);  //os.EOL:操作系统的换行符
    15 console.log('................................................');
    16 console.log('................................................');
    17 showObj(os.cpus());
    18 console.log('................................................');
    19 console.log('................................................');
    20 showObj(os.networkInterfaces());
    21 console.log('................................................');
    22 console.log('................................................');
    23 showObj(os.loadavg());
    24 
    25 
    26 
    27 
    28 function showObj(obj){
    29     if (obj == null) {
    30         console.log('error: ' + obj);    
    31         return false;
    32     }
    33     for (var key in obj)    {
    34         //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.)
    35 if (typeof(obj[key]) == 'array' || typeof(obj[key]) == 'object') { 36 showObj(obj[key]); 37 } else { 38 if (obj[key] != null) 39 console.log(key + "=" + obj[key]); 40 } 41 } 42 } 43

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

  • 相关阅读:
    异常处理(throw,throws,try,catch,finally)
    内部类、匿名内部类、静态内部类
    Object,equals,toString
    有关于多态和静态绑定与动态绑定的知识
    接口的基本知识
    关于继承的基本知识,方法重写,final和abstract的使用, 动态绑定和静态绑定的知识
    设计模式: 单列设计模式 、模块方法设计模式、装饰设计模式、工厂设计模式、适配器设计模式
    zabbix设置维护周期
    zabbix入门
    yum安装zabbix 5.0 LTS
  • 原文地址:https://www.cnblogs.com/chenchenluo/p/4227993.html
Copyright © 2011-2022 走看看