NagiosEnterprises / ncpa

Nagios Cross-Platform Agent
Other
177 stars 95 forks source link

Wrong swap percent being returned on windows NCPA #807

Closed etsorbme closed 2 years ago

etsorbme commented 3 years ago

Windows is calculating swap incorrectly. Linux calculates correctly and as expected. I can run python using the module (psutils) that they mention which shows this. Examples of both Windows and Linux are below.

Taking my laptop as an example (though we have also tested server in the past with the same inaccurate results). Windows performance monitor reports 5% swap/page file usage.

Directly running the python module they use to pull this info

psutil.virtual_memory()

svmem(total=16953987072, available=7974776832, percent=53.0, used=8979210240, free=7974776832)

psutil.swap_memory()

sswap(total=23396438016, used=14038126592, free=9358311424, percent=60.0, sin=0, sout=0)

First command shows total physical memory (RAM). The second is supposed to be showing swap, but actually is calculating total available virtual memory (including swap.) I have a 6 GB swap file, I do not have a 22 GB swap file and swap is not using 14 GB. It is adding both swap and the physical memory together to report the total and I’m not completely sure what it is adding together to get the used value.

MrPippin66 commented 3 years ago

I think is actually a bug in psutil. Not sure which version you downloaded.

https://github.com/giampaolo/psutil/pull/1927

This was put in psutil back in March, so wouldn't have been in the last ncpa client.

Hopefully, will get pulled into the next NCPA build.

jomann09 commented 2 years ago

This should be fixed in the next version, 2.4.0 - the new psutil will be bundled in that.

ccztux commented 2 years ago

As described in https://github.com/NagiosEnterprises/ncpa/issues/844 i dont think this is fixed with version 2.4.0.

gittethis commented 2 years ago

-i've built (2.4.0) with psutil 5.9.2 (latest(?)) and encountered the "memory/swap" bug. -pipuninstalled it and downgraded to 5.8.0, built again and the swap bug is gone..