Get Express Package CPU, RAM and Disk to display for my Discord Bot

Hi @Fyrlex!

You can read these files:

/sys/fs/cgroup/memory/memory.soft_limit_in_bytes
/sys/fs/cgroup/memory/memory.stat
/sys/fs/cgroup/cpu/cpu.cfs_quota_us
/sys/fs/cgroup/cpu/cpu.cfs_period_us
/sys/fs/cgroup/cpu/cpuacct.usage

For the values you see in the Status pane, memory usage is the total_rss line from/sys/fs/cgroup/memory/memory.stat minus Node’s process.memoryUsage().rss. Disk space comes from the check() method from the NPM package diskusage.

The percentages we display in the status bar are calculations over sliding averages of historical data, and we tweak these a little periodically to provide better info. You’re unlikely to be able to achieve an exact match for those values at any given point.

Hope this helps!

4 Likes