Facepunch / garrysmod-requests

Feature requests for Garry's Mod
84 stars 24 forks source link

Expose the results of the `stats` command to Serverside Lua. #1346

Open NanoAi opened 5 years ago

NanoAi commented 5 years ago

Sometimes you want to see how your server is preforming within Lua, or even do actions when performance gets low.

So it would be really nice to be able to access details such as... CPU, In(KB/s), Out(KB/s), Uptime, Map_changes, FPS, Players, Connects

I know some of these things are already available but again it would be quite nice to have access to everything here.

Kefta commented 5 years ago

Uptime: https://wiki.garrysmod.com/page/Global/SysTime or https://wiki.garrysmod.com/page/Global/RealTime FPS: requested in https://github.com/Facepunch/garrysmod-requests/issues/482 Players: https://wiki.garrysmod.com/page/player/GetCount Connects: Can be logged with the PlayerConnect hook, but could be binded since it's already tracked Map_changes: Could be logged with a file or pdata but would easily be inaccurate if the server crashes and GM:Shutdown isn't called to clear the value

No way to get In/Out network load or CPU usage

NanoAi commented 5 years ago

You sure there's no way? The "stats" command seems to print it in console, as well as CPU usage.

Also odd that it didn't come up when I searched for related issues... Probably because I typed FPS...

Kefta commented 5 years ago

I meant "no way" from the Lua state with current bindings, as in there are no alternate solutions.

Kefta commented 5 years ago

CPU usage: https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/engine/baseserver.h#L90 Net in/out: https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/engine/baseserver.h#L87 Changelevels: https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/engine/baseserver.h#L84 (don't know why this has a seemingly unrelated name)