GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — peer-stream/systemIO.js at main · AdaSeraph/peer-stream

Expand file tree

/

systemIO.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
87 lines (74 loc) · 2.27 KB
/

systemIO.js

Copy path

File metadata and controls

87 lines (74 loc) · 2.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const os = require('os');
const nodeCmd = require('node-cmd');
const serverInfo = {
cpuUsage: 0,
gpuUsage: 0,
freeMem: 0,
totalMem: 0
}
var dealTime = (seconds)=>{
var seconds = seconds|0;
var day = (seconds/(3600*24))|0;
var hours = ((seconds-day*3600)/3600)|0;
var minutes = ((seconds-day*3600*24-hours*3600)/60)|0;
var second = seconds%60;
(day<10)&&(day='0'+day);
(hours<10)&&(hours='0'+hours);
(minutes<10)&&(minutes='0'+minutes);
(second<10)&&(second='0'+second);
return [day,hours,minutes,second].join(':');
};
var dealMem = (mem)=>{
var G = 0,
M = 0,
KB = 0;
(mem>(1<<30))&&(G=(mem/(1<<30)).toFixed(2));
(mem>(1<<20))&&(mem<(1<<30))&&(M=(mem/(1<<20)).toFixed(2));
(mem>(1<<10))&&(mem>(1<<20))&&(KB=(mem/(1<<10)).toFixed(2));
return G>0?G+'G':M>0?M+'M':KB>0?KB+'KB':mem+'B';
};
//cpu架构
const arch = os.arch();
console.log("cpu架构:"+arch);
//操作系统内核
const kernel = os.type();
console.log("操作系统内核:"+kernel);
//操作系统平台
const pf = os.platform();
console.log("平台:"+pf);
//系统开机时间
const uptime = os.uptime();
console.log("开机时间:"+dealTime(uptime));
//主机名
const hn = os.hostname();
console.log("主机名:"+hn);
//主目录
const hdir = os.homedir();
console.log("主目录:"+hdir);
//内存
const totalMem = os.totalmem();
const freeMem = os.freemem();
console.log("内存大小:"+dealMem(totalMem)+' 空闲内存:'+dealMem(freeMem));
//cpu
const cpus = os.cpus();
console.log('*****cpu信息*******');
cpus.forEach((cpu,idx,arr)=>{
var times = cpu.times;
console.log(`cpu${idx}:`);
console.log(`型号:${cpu.model}`);
console.log(`频率:${cpu.speed}MHz`);
console.log(`使用率:${((1-times.idle/(times.idle+times.user+times.nice+times.sys+times.irq))*100).toFixed(2)}%`);
});
//网卡
console.log('*****网卡信息*******');
const networksObj = os.networkInterfaces();
for(let nw in networksObj){
let objArr = networksObj[nw];
console.log(`\r\n${nw}:`);
objArr.forEach((obj,idx,arr)=>{
console.log(`地址:${obj.address}`);
console.log(`掩码:${obj.netmask}`);
console.log(`物理地址:${obj.mac}`);
console.log(`协议族:${obj.family}`);
});
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.