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.
Eg: message.author.send(("Memory used in GB", ((usedMemory/ Math.pow(1024, 3)).toFixed(2)));
Also don't forget to add those missing semicolons :)
I dont need to specify which channel, it is in a client.on('message', async message => {}. And here is the image of what u said.
@WilliamPenrod
why doesn't it work?
it says the text, but it says nothing after that. No errors or anything, it just leaves it blank. It worked too when i hosted it on my [email protected]
I am not familiar with Discord.js, but your code to get the percentage is correct. (besides using var
instead of let
or const
, but that's not to big of a deal... Just best-practice to prevent memory vulnerabilities) Maybe check out the Discord.js documentation?
@JohnS4 Hi,
I think this website might help you a lot.
Click here
Thanks!
Hope this helps
@JohnS4
Happy to help you!
Thanks!
Quick question. it worked. But it says this.

Are those my stats combined with other peoples, or are those my individual project stats?
@PattanAhmed
@JohnS4 I think combined!
Thanks!