CPU assign to Glitch

So, for some reason, the last few days when I was doing the command to check my bot’s statistics, I kept seeing this, which wasn’t really good for me: image
And my bot keeps getting offline for no reason and I’ve done a lot of things to keep the bot online 24/7.

From a Discord Bot Developer and Glitch User,
TehPig_YT

What you have provided is no where near useful. Could you provide us with a project link? Note make sure its public so we can see it, before doing that, make sure all sensitive things like bot tokens are in your ENV

1 Like

The only thing that I can provide is the whole command code, so here it is:

this has been edited

From a Discord Bot Developer and Glitch User,
TehPig_YT

1 Like

The module you are using fetches CPU percentage from the server itself, not your actual project.

1 Like

So, the actual CPU of the bt is the Glitch’s Project CPU?

From a Discord Bot Developer and Glitch User,
TehPig_YT

Yes, your best bet is to get the processes CPU usage, which may not entirely show your whole project’s CPU usage, but should show the usage of the bot itself. Take a look at this

I’m not sure if I have done it right but I managed to get a different amount of CPU:
image
With the Glitch Project showing:
image
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,
TehPig_YT

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:
image

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.

/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

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:

/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

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.