How can I get the stats of my project?

I wanna know how can I get the stats of my project, like the memory usage, cpu usage of the app, disk usage? I’m new to this, so yeah.

Anything like local cpuusage = app.stats:Get(ProcessorUsage) for the cpu percentage (this is a Luascript example) would be great enough! I just want to know about CPU, Memory and the Disk Usage.

Thanks in advance!

3 Likes

Thanks, man! I could not find anything for the stats, but here we go!

2 Likes

Or, try this - https://www.npmjs.com/package/express-status-monitor

2 Likes

Is there a way to use express status monitor to only bring the values, and send them through another way?

For example, My bot would respond to the stats command and then it’d send these values.

1 Like

I actually haven’t used this package - let me look at the docs real quick.

I looked at this site - https://hackathon-starter.walcony.com/status - (the demo) and I have no clue where the data is coming from. It seems to be something doing with a sockets connection.

Try this: https://archive.is/snUHt

2 Likes

Well, the thing is, I don’t want to launch a website just to get the status. But I just found this. I’ll give it a try. I’ll post what I got with it!

Hmm, it throws an error. Seems like its only for Linux?

usage: cannot find pre-compiled binary for: linux/x64/v12.0.0
usage: failed loading provider linux

Apologies for the poor formatting! :sweat_smile:

2 Likes

That’s cool!
Works on OSX, Linux, SmartOS and Solaris <- from the NPM page.
Glitch’s servers might be using a different OS? Try emailing support@glitch.com

2 Likes

Yeah, I’ll mail them about it. I’ll tell changes here

2 Likes

Hi @mahmoud34abc,

While Linux should work, you may have issues with this package since it appears to be rather old and unmaintained. So it may not work with more recent versions of node.

One of our friendly engineers suggested that you try this package instead:
https://github.com/soyuka/pidusage just be sure to note that the readme points out the following:

Please note that if you need to check a Node.JS script process cpu and memory usage, you can use process.cpuUsage and process.memoryUsage since node v6.1.0. This script remain useful when you have no control over the remote script, or if the process is not a Node.JS process.

I will copy this information over to your support request for easy reference. If you have additional questions, feel free to ask them here or in your support request. Whatever works best for you!

6 Likes

Thanks, @tasha and @CarlyRaeJepsenStan! Really appreciate both of your help!

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!
Edits: fixing misspell and stuff!

3 Likes

Awesome! Definitely bookmarking this.

1 Like