-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
107 lines (77 loc) · 2.71 KB
/
index.js
File metadata and controls
107 lines (77 loc) · 2.71 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const express = require('express');
const os = require('os');
const si = require('systeminformation');
const bodyParser = require('body-parser');
const { exec } = require('child_process');
const app = express();
const port = 4000;
app.get('/computerName', (req, res) => {
const computerName = os.hostname();
res.json({ computerName });
});
app.get('/system', (req, res) => {
const cpuUsage = os.cpus()[0].times;
const totalMemory = os.totalmem();
const freeMemoryInfo = os.freemem();
const cpuName = os.cpus()[0].model;
const memoryUsage = Math.random() * 100;
const diskInfo = os.platform() === 'win32' ? os.cpus()[0] : os.cpus(); // Csak Windows esetén van használható 'os.cpus()' érték
// Százalékos formában kiszámoljuk a CPU-használatot és a memória-használatot
const cpuUsagePercent = ((cpuUsage.user + cpuUsage.sys) / (cpuUsage.user + cpuUsage.sys + cpuUsage.idle)) * 100;
const memoryUsagePercent = ((totalMemory - freeMemoryInfo) / totalMemory) * 100;
res.json({
cpuUsage: cpuUsagePercent,
memoryUsage: memoryUsagePercent,
totalMemoryInfo: totalMemory,
freeMemoryInfo: freeMemoryInfo,
diskInfo: diskInfo
});
});
app.get('/disk', async (req, res) => {
try {
const diskInfo = await si.fsSize();
res.json({ diskInfo: diskInfo });
} catch (error) {
console.error('Error fetching disk information:', error);
res.status(500).json({ error: 'Internal Server Error' });
}
});
// Middlewares
app.use(bodyParser.json());
// Your other routes and middleware...
// Start the server
// Példa hiba: hiányzik egy lezáró zárójel az alábbi sor végén
// Hiányzik a lezáró zárójel az alábbi sor után
app.get('/', (req, res) => {
res.render('index.ejs');
});
app.get('/storage-test', (req, res) => {
res.render('storage.ejs');
});
app.get('/storage', (req, res) => {
res.render('storage2.ejs');
});
app.post('/stop', (req, res) => {
res.render('function.ejs');
});
app.post('/stop-server', (req, res) => {
// Indítás
serverProcess = child_process.spawn('npm', ['start', '--', '--host=0.0.0.0', '--port=3000']);
res.send('Process started!');
});
app.get('/console', (req, res) => {
res.render('konzol.ejs');
});
app.get('/dashboard', (req, res) => {
res.render('eyeverhome.ejs');
});
app.get('/powerkill', (req, res) => {
res.render('powerkill.ejs');
});
app.get('/status', (req, res) => {
res.render('status.ejs');
});
app.use(express.static('public'));
app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});