diff options
Diffstat (limited to 'index.ts')
-rw-r--r-- | index.ts | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..cad077a --- /dev/null +++ b/index.ts @@ -0,0 +1,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, () => {
+ console.log("Status poller started on polling port (72937).");
+});
|