tabarra / txAdmin

The official FiveM server management platform used by over 23k servers!
https://txadmin.gg/
MIT License
811 stars 546 forks source link

[BUG] WMIC not available on newer Windows versions. #970

Open Ed3n18 opened 3 months ago

Ed3n18 commented 3 months ago

txAdmin/FXServer versions: txAdmin: v7.2.2 FxServer: b9073

Describe the bug An error appears on the CMD console after server loads correctly "[tx:WebServer:DiagnosticsFuncs] Error getting processes tree usage data."

To Reproduce Steps to reproduce the behavior:

  1. Start/Run the server
  2. Wait for it to load all the scripts
  3. Starts showing the error without stopping

Expected behavior Shouldn't be any errors

Screenshots image

Additional context Server is hosted on Windows Server 2025, might be a problem getting system info?

tabarra commented 3 months ago

Your server likely doesn't have WMIC or PS enabled.
This is not a txadmin bug.

edit: yes, it's a txAdmin bug

Ed3n18 commented 3 months ago

Do you mean the Windows Management Instrumentation Service and PowerShell?

tabarra commented 3 months ago

Yes.
For further support, please join discord.gg/txAdmin

Ed3n18 commented 3 months ago

I have no problem going to Discord, but don't you want other people to find this in the future?

I have the WMI service up and running and tried using PowerShell to run FXServer.exe and it still shows the error

tabarra commented 3 months ago

If you go to System -> Console Log it will show you more information.
This is a known issue for servers where pidusage cannot get the information.
This is caused by linux servers not having procps (ps util) installed, and on windows when there is some error accessing PS or WMIC.
Unless you find out the issue is something else, there is not really much for me to add.

Ed3n18 commented 3 months ago

Its strange cause i have both, but i have read that WMIC is deprecated so maybe thats it? but im not sure i you can enable it manually. I will investigate "Error: spawn wmic ENOENT" further.

This is the error, which says wmic.

image

tabarra commented 3 months ago

Ahh I see...

Beginning with Windows Server 2025, WMIC is available as a feature on demand (FoD) which can be added with the DISM /Add-Capability command.

Apparently the same applies to Windows 11.
The bad news is that the libraries that I use are abandoned and they wont be updated to support the new PS WMI thingy, meaning a fix for this issue is really not expected in the short or near future. The good news is that for the next update, I already changed the svRuntime monitoring thingy to not print errors, and to only call WMIC once instead of twice, so it should not spam these errors.
And I think WMIC is not used anywhere else other than the diagnostics page, and to detect the OS name (with PS fallback).
So, althought this issue is solvable, I guess no reason to prioritize doing any changes other than what was already done.

Thank you for letting me know, I'm adding adding this to the infinitely growing TO-DO list.
For now, I recommend you just install the additional windows feature.

Ed3n18 commented 3 months ago

Okay so there are 3 ways to fix this;

After that I added "%SystemRoot%\System32\Wbem" to User PATH

Now txAdmin shows "FXServer Memory" which before it didn't. Also would be nice to see CPU Usage? :) image

Thank you for helping!

Techdude404Gaming commented 2 months ago

Wanted to post here because I know others are going to be searching for this. Also put this in the txAdmin Discord.

Hey all, in case anyone is looking for the fix to having this error on a pterodactyl linux branch: [tx:WebServer:DiagnosticsFuncs] Error getting processes tree usage data.

I have found a fix. Just use this fivem egg from Luxxy-GF (it's a bit different from the base parkervcp version) It appears her docker image fixes things. (I've modified the variables slightly for my own ease of use, but the egg is perfectly fine by itself.) https://github.com/Luxxy-GF/pterodactyl-fivem

Hope this helps someone! I've seen a lot of people asking about this issue in this server, wanted to point to a solution for all.

tabarra commented 2 months ago

Perker's version fixes the issue, but most hosts haven't updated their egg in years.

Techdude404Gaming commented 2 months ago

Perker's version fixes the issue, but most hosts haven't updated their egg in years.

I am my own host and was not able to replicate the fix with parker's egg unfortunately. I don't know if that's a me thing or not, but this new one seems to work for me. 🤷

tabarra commented 2 months ago

I guess I should highlight that "parker's egg" is now on another link. Looks like he moved the repo.
This is the referenced commit: https://github.com/pelican-eggs/yolks/commit/57e3ef41ed05109f5e693d2e0d648cf4b161f72c

But Luxxy-GF's image sounds way leaner, so might be worth trying to use it as well.
Who knows... one day I might roll out my own dockerfile and egg.

tabarra commented 2 months ago

(note to future self)
How to use Get-WmiObject to get the data:

Get-WmiObject Win32_Process -Filter 'ProcessId=18340 or ProcessId=29624' |
Select-Object Name,CommandLine,CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize |
ConvertTo-Json

Calculating (consider the values are in 100ns intervals)

CPU Usage (%) = [((UserModeTime2 + KernelModeTime2) - (UserModeTime1 + KernelModeTime1)) / 10,000,000] / (Total Time Elapsed * Number of Cores) * 100

Instead of calculating using the number of cores available, perhaps it's worth to calculate using the max number of cores used by fxserver?