Node.js/系统信息
来自康健生活
< Node.js
os
const os = require('os');
| 功能 | 方法名 | 说明 |
|---|---|---|
| 获取cpu(处理器架构) | os.arch() | |
| 获取cpu信息 | os.cpus() | |
| 字节顺序 | os.endianness() | 高位优先返回BE,低位优先的返回LE |
| 空闲内存字节 | os.freemem() | |
| 当前登录用户的根目录 | os.homedir() | |
| 操作系统主机名 | os.hostname() | |
| 系统最近5、10、15分钟的平均负载 | os.loadavg() | 这是一个针对linux或unix的统计,windows下始终返回[0,0,0] |
| 网络配置列表 | os.networkInterfaces() | |
| 操作系统类型 | os.platform() | 返回值有'darwin', 'freebsd', 'linux', 'sunos' , 'win32' |
| 操作系统版本 | os.release() | |
| 操作系统临时文件的默认目录 | os.tmpdir() | |
| 系统总内存 | os.totalmem() | |
| 操作系统名称 | os.type() | 基于linux的返回linux,基于苹果的返回Darwin,基于windows的返回Windows_NT |
| 计算机正常运行时间 | os.uptime() |
systeminformation
npm install systeminformation --save
const si = require('systeminformation');
// promises style - new since version 3
si.cpu()
.then(data => console.log(data))
.catch(error => console.error(error));
osx-temperature-sensor
npm install osx-temperature-sensor --save
lm-sensors
sudo apt-get install lm-sensors
smartmontools
sudo apt-get install smartmontools
No categories