How to see ram and cpu usage
I am making a discord.js bot, and I was wondering if I can see how much ram and cpu usage I am using. I am hosting this off of repl, with some files and such. I have tried doing
var os = require('os'); var usedMemory = os.totalmem() -os.freemem(), totalMemory = os.totalmem(); var getpercentage = ((usedMemory/totalMemory) * 100).toFixed(2) + '%' message.channel.send("Memory used in GB", (usedMemory/ Math.pow(1024, 3)).toFixed(2)) message.channel.send("Used memory" , getpercentage);
but that does not work. any help?
Based on your example, you're not specifying the channel to send it to. You need to set the "channel" id or use the reply function.
message.author.send(("Memory used in GB", ((usedMemory/ Math.pow(1024, 3)).toFixed(2)));
Also don't forget to add those missing semicolons :)
I am not familiar with Discord.js, but your code to get the percentage is correct. (besides using
var instead of
const, but that's not to big of a deal... Just best-practice to prevent memory vulnerabilities) Maybe check out the Discord.js documentation?