Giter Club home page Giter Club logo

Comments (13)

WilliamVenner avatar WilliamVenner commented on June 18, 2024

Extract from the docs for the upstream function

Returns the total CPU usage (in %). Notice that it might be bigger than 100 if run on a multicore machine.

If you want a value between 0% and 100%, divide the returned value by the number of CPU processors.

Warning: If you want accurate CPU usage number, better leave a bit of time between two calls of this method (200 ms for example).

This is what I do:

*cpu_usage = (process.cpu_usage() as f64) / (*LOGICAL_CPUS as f64);

I believe this is sound. Can you check if you can reproduce this on Windows?

from gmsv_serverstat.

FlorianLeChat avatar FlorianLeChat commented on June 18, 2024

On Windows (and on Windows Server with a dedicated server), it seems these values are perfectly normal.

] lua_run PrintTable(serverstat.All())
> PrintTable(serverstat.All())...
LogicalCPUs	=	8
PhysicalCPUs	=	4
ProcessCPUUsage	=	6.8244895935059
ProcessMemoryUsage	=	634.419921875
SystemAvailableMemory	=	7734.50390625
SystemCPUUsage	=	16.620286941528
SystemMemoryUsage	=	8981.4033203125
SystemTotalMemory	=	16715.907226563
] lua_run serverstat.async.All(function(data) PrintTable(data) end)
> serverstat.async.All(function(data) PrintTable(data) end)...
LogicalCPUs	=	8
PhysicalCPUs	=	4
ProcessCPUUsage	=	9.4401035308838
ProcessMemoryUsage	=	635.7470703125
SystemAvailableMemory	=	7742.8876953125
SystemCPUUsage	=	11.839296340942
SystemMemoryUsage	=	8973.01953125
SystemTotalMemory	=	16715.907226563

But sometimes the SystemCPUUsage field returns 0 even if it has been previously called. I also tested this on another dedicated server but this time under CentOS 8 and I experience exactly the same problem described above.

from gmsv_serverstat.

WilliamVenner avatar WilliamVenner commented on June 18, 2024

@FlorianLeChat Can you test with v0.2.4?

from gmsv_serverstat.

FlorianLeChat avatar FlorianLeChat commented on June 18, 2024
lua_run serverstat.async.All(function(data) PrintTable(data) end)
> serverstat.async.All(function(data) PrintTable(data) end)...
LogicalCPUs     =       1
PhysicalCPUs    =       1
ProcessCPUUsage =       9100
ProcessMemoryUsage      =       548.36328125
SystemAvailableMemory   =       1802.69921875
SystemCPUUsage  =       5.363748550415
SystemMemoryUsage       =       1448.689453125
SystemTotalMemory       =       3727.6279296875

I still get the problem unfortunately. The server is a VPS with 1 vCore and running CentOS 8. On Windows (and Windows Server), everything works perfectly.

from gmsv_serverstat.

WilliamVenner avatar WilliamVenner commented on June 18, 2024

@FlorianLeChat Looks like sysinfo may have made some fixes since, please give v0.2.5 a try.

from gmsv_serverstat.

FlorianLeChat avatar FlorianLeChat commented on June 18, 2024

The problem is still there, unfortunately.

lua_run serverstat.async.All(function(data) PrintTable(data) end)
> serverstat.async.All(function(data) PrintTable(data) end)...
LogicalCPUs     =       2
PhysicalCPUs    =       2
ProcessCPUUsage =       0
ProcessMemoryUsage      =       925.6171875
SystemAvailableMemory   =       1345.5234375
SystemCPUUsage  =       4.6325511932373
SystemMemoryUsage       =       2071.0537109375
SystemTotalMemory       =       3728.015625
lua_run serverstat.async.All(function(data) PrintTable(data) end)
> serverstat.async.All(function(data) PrintTable(data) end)...
LogicalCPUs     =       2
PhysicalCPUs    =       2
ProcessCPUUsage =       100
ProcessMemoryUsage      =       925.625
SystemAvailableMemory   =       1345.3671875
SystemCPUUsage  =       5.5462183952332
SystemMemoryUsage       =       2071.2099609375
SystemTotalMemory       =       3728.015625
Protocol version 24
Exe version 2021.06.09 (garrysmod)
Exe build: 14:56:57 Jul 12 2021 (8283) (4000)
GMod version 2021.07.12, branch: unknown
Linux 32bit Dedicated Server

(Always under CentOS 8)

from gmsv_serverstat.

WilliamVenner avatar WilliamVenner commented on June 18, 2024

Is the issue isolated to only CentOS? Do you know if it happens on other distros?

from gmsv_serverstat.

FlorianLeChat avatar FlorianLeChat commented on June 18, 2024

This is what I also said to myself when I wrote my answer just before, I have a feeling that CentOS might be the problem. I'm very tempted to install Debian and/or Ubuntu Server on a virtual machine tomorrow to test that.

from gmsv_serverstat.

WilliamVenner avatar WilliamVenner commented on June 18, 2024

If we can only reproduce this on CentOS, I can let the maintainer of sysinfo know and he can implement a fix.

from gmsv_serverstat.

FlorianLeChat avatar FlorianLeChat commented on June 18, 2024

image
image

I just did the test under Debian 11/Ubuntu 21.10 and I get the same problem (even when switching to the 64 bits version of the dedicated server).

from gmsv_serverstat.

WilliamVenner avatar WilliamVenner commented on June 18, 2024

This is just weird. My Ubuntu 16 is fine:

image

from gmsv_serverstat.

FlorianLeChat avatar FlorianLeChat commented on June 18, 2024

This issue is really confusing 😕

For more information, the tests I did today were done under VMWare 16 with the latest OS images and I installed a fresh new Garry's Mod server using LinuxGSM.

from gmsv_serverstat.

WilliamVenner avatar WilliamVenner commented on June 18, 2024

Ok, mine's under WSL. I doubt LinuxGSM could be doing that.

from gmsv_serverstat.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.