CPU assign to Glitch

I’m not sure if I have done it right but I managed to get a different amount of CPU:
With the Glitch Project showing:
And Using the following code:

this has been edited

The rest of the code is not posted due to being for other fields of the embed.

From a Discord Bot Developer and Glitch User,

So, how can I improve this and make it say the actual percentage of my project?

Multiple Glitch projects run on a single AWS EC2 instance. When you try get the CPU usage it shows for all of the projects in that EC2 server combined together.

I’m looking forward to making something like this:

1 Like

@TehPig_YT For that, you may want to run it on a RasberryPi or a separate computer. Just like what xXProGamerXx said. You will either have to deal with that or self host it. But that CPU stuff isn’t needed really for a bot info.

1 Like

I can tell you that some bot developers have achieved to do it using Glitch, so what you’re saying is not helpful at all.

Hm…if you wanted to get the percentage of available CPU specific to the container (as opposed to the actual disk) that sounds like a docker issue, right? I’m not a docker expert but this might be closer to what you’re looking for.

Nevermind, I couldn’t understand a lot from that but it’s still something.

I have found some information about this issue but I still cannot understand how to use them right.


Anyways, I’ve solved my problem somehow. Thank you for your help everyone!

1 Like

Hey-- Do you mind if you send the command’s code on how you did it? I don’t understand how to use these:


so it’d be great if you shared here how you did it, specially that the current marked solution… actually does not house a solution. Thanks in advance!

long ass thread haha

This is over a year old, the owner might not be active.

Well, I hope the owner is still active. I really need a way to get the usage of CPU and Memory.

@TehPig_YT was online 10 days ago. They might come back on sooner than later.

1 Like

I believe you can try to use the fs module’s readFile or readFileSync to get the content of these files?

1 Like

I’ll try that out. If it works, I’ll post here!

Thanks for bringing that up!

Got it, but its a whole mess.

  • The Files

/sys/fs/cgroup/memory/memory.stat shows the next:

cache 2170880
rss 100937728
rss_huge 0
mapped_file 0
dirty 32768
writeback 0
pgpgin 162858
pgpgout 137685
pgfault 323849
pgmajfault 0
inactive_anon 50585600
active_anon 50352128
inactive_file 122880
active_file 2048000
unevictable 0
hierarchical_memory_limit 6442450944
total_cache 2170880
total_rss 100937728
total_rss_huge 0
total_mapped_file 0
total_dirty 32768
total_writeback 0
total_pgpgin 162858
total_pgpgout 137685
total_pgfault 323849
total_pgmajfault 0
total_inactive_anon 50585600
total_active_anon 50352128
total_inactive_file 122880
total_active_file 2048000
total_unevictable 0







  • What I noticed:

hierarchical_memory_limit 6442450944 --(If this is Bits, then it is 768 megabytes. (Divided by 8 to change from bit to byte, and then 1024 to kilobyte, then megabyte.) (Google divides by 1000, and the calculation was 805.306368.)

I’ll try finding a way to grab information out of that.

If anybody else has an idea about this, say it here!

Hmm… what are cache and rss? I’m looking for a number that’s larger than 4833615992

1 Like

Great news! Just contacted Glitch support and they replied! I’m using pidusage, and it’s awesome!

Here is the code for anyone else!! (I know that I should be using a command processor instead. I’ll migrate to that in the future.

client.on("message", message => {
  if (message.content == "m!stats") {
    pidusage(process.pid, function (err, stats) {
      message.channel.send("CPU: " + stats.cpu + "%\nMemory Usage: " + stats.memory + " bytes");

Just make sure to remember to put var pidusage = require('pidusage') at the start of the code!

Thanks everyone that helped! Really love Glitch’s community (nohomo)