-
Notifications
You must be signed in to change notification settings - Fork 1
/
deno.js
23 lines (20 loc) · 818 Bytes
/
deno.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { SHELL: shell, TERM: term, USER: user } = Deno.env.toObject();
const host = Deno.readTextFileSync("/etc/hostname").trimRight();
const kernel = Deno.readTextFileSync("/proc/version").split(" ")[2];
const tasks =
Array.from(Deno.readDirSync("/proc")).filter((x) => Number(x.name)).length;
const mem = Deno.readTextFileSync("/proc/meminfo").split("\n").slice(0, 3);
const [total, _, avail] = mem.map((x) =>
Math.floor(Number(x.match(/\d+/))) / 1000
);
const uptime = Number(Deno.readTextFileSync("/proc/uptime").split(" ")[0]);
const d = Math.floor(uptime / 60 / 60 / 24);
const h = Math.floor(uptime / 60 / 60 % 24);
const m = Math.floor(uptime / 60 % 60);
console.log(`${user}@${host}
kernel\t${kernel}
term\t${term}
shell\t${shell}
tasks\t${tasks}
mem\t${avail}m / ${total}m
uptime\t${d}d ${h}h ${m}m`);