forked from dojonode/dojonode-systeminformation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (27 loc) · 799 Bytes
/
server.js
File metadata and controls
34 lines (27 loc) · 799 Bytes
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
const express = require('express');
const si = require('systeminformation');
const cors = require('cors');
const app = express();
const port = 3009;
// Start new timer on startup, to keep track of runtime
const startTime = Math.floor(new Date() / 1000);
app.use(cors({
origin: '*'
}));
app.get('/metrics', async (req, res) => {
const mem = await si.mem();
const cpu = await si.currentLoad();
const disk = await si.fsSize();
// const dockerContainers = await si.dockerContainers();
// const docker = dockerContainers.find(dc => dc.name === "simple-taiko-node-taiko_client_driver-1");
const metrics = {
mem,
cpu,
disk,
startTime
};
res.json(metrics);
});
app.listen(port, () => {
console.log(`Metrics API listening at http://localhost:${port}/metrics`);
});