aboutsummaryrefslogtreecommitdiff
path: root/index.ts
diff options
context:
space:
mode:
authorCloudburstSys <us@conep.one>2022-05-19 21:17:17 +0100
committerCloudburstSys <us@conep.one>2022-05-19 21:19:47 +0100
commit36bc64d889d2cdc53bf81886765e2f372bc1f7f9 (patch)
treeb38ba3abcd688df05c986d98b1d7f89c20a7fcc9 /index.ts
parent521f1ef9793f19544207a56bcb821f8a5a7f8950 (diff)
downloadvaportrail-statuspoller-36bc64d889d2cdc53bf81886765e2f372bc1f7f9.tar.gz
vaportrail-statuspoller-36bc64d889d2cdc53bf81886765e2f372bc1f7f9.tar.bz2
vaportrail-statuspoller-36bc64d889d2cdc53bf81886765e2f372bc1f7f9.zip
yes
Diffstat (limited to 'index.ts')
-rw-r--r--index.ts59
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).");
+});