OSUtil

OSUtil

new OSUtil()

Source:
Author:
  • ycx <link>http://nodejs.cn/api/os.html#os_os_homedir<link> 系统工具

Methods

(static) getArch() → {string}

Source:
获取当前系统架构 x86 x64 arm
Returns:
Type
string

(static) getCpus() → {Array.<CpuInfo>}

Source:
获取cpu信息 例如我的cpu信息如下:
{ model: 'Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz', speed: 3099, 以兆赫兹为单位 times: { user: 9491360, CPU 在用户模式下花费的毫秒数 nice: 43660, CPU 在良好模式下花费的毫秒数 sys: 2884860, CPU 在系统模式下花费的毫秒数 idle: 15414210, CPU 在空闲模式下花费的毫秒数 irq: 640500 CPU 在中断请求模式下花费的毫秒数 } }
Returns:
Type
Array.<CpuInfo>

(static) getEOL() → {string}

Source:
获取操作系统特定的行末标志
1,在 POSIX 上是 \n。 2,在 Windows 上是 \r\n。
Returns:
Type
string

(static) getFreemem() → {number}

Source:
获取当前系统剩余内存 (以字节为单位)
Returns:
Type
number

(static) getHostName() → {string}

Source:
获取hostname
Returns:
hostname
Type
string

(static) getIPV4Address()

Source:
获取系统ipv4 地址
Returns:

(static) getIPV6Address()

Source:
获取系统的ipv6地址
Returns:

(static) getPlatform() → {NodeJS.Platform}

Source:
获取当前操作系统所属平台
例如: linux ,android,win32等
Returns:
操作系统所属平台字符串
Type
NodeJS.Platform

(static) getTotalmem() → {number}

Source:
获取当前系统总内存(以字节为单位)
Returns:
Type
number

(static) getUptime() → {number}

Source:
获取系统 运行时间 (以秒为单位)
Returns:
Type
number

(static) getUserInfo(options) → {UserInfo.<Buffer>}

Source:
获取当前用户信息 例如我的信息如下:
{ uid: 1000, gid: 1000, username: 'yichengxian', homedir: '/home/yichengxian', shell: '/bin/zsh' }
Parameters:
Name Type Description
options
Returns:
Type
UserInfo.<Buffer>

(static) getVersion() → {string}

Source:
获取操作系统版本
注意 不是获取node版本
Returns:
Type
string