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
|
import express from "express";
import si from "systeminformation";
const app = express();
app.get("/json", async (req, res) => {
// Gives the info for this server
let cpu = await si.cpu();
let cpuSpeed = await si.cpuCurrentSpeed();
let temp = await si.cpuTemperature();
let memory = await si.mem();
let os = await si.osInfo();
let time = si.time();
let load = await si.currentLoad();
let processes = await si.processes();
let uptime = parseInt(time.uptime) * 1000;
res.json({
name: os.hostname,
cpu: {
processors: cpu.processors,
model: `${cpu.manufacturer} ${cpu.brand}`,
cores: cpu.cores,
speed: cpuSpeed.avg,
temperature: temp.main,
processes: {
total: processes.all,
running: processes.running,
sleeping: processes.sleeping,
blocked: processes.blocked,
unknown: processes.unknown
},
load: load.currentLoadSystem
},
memory: {
swap: {
used: memory.swapused,
free: memory.swapfree,
total: memory.swaptotal
},
physical: {
used: memory.used,
free: memory.free,
total: memory.total
}
},
os: {
name: os.distro,
version: os.release
},
uptime: uptime,
version: "1.0.0"
});
});
app.listen(52937).then(() => {
console.log("listening!");
});
|