NagiosEnterprises / ncpa

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

Swap fails on Windows when upgrading to v2.4.1 #1000

Open shoreypu opened 9 months ago

shoreypu commented 9 months ago

Upgraded from 2.40 to 2.4.1, and swap checks are failing (all of our other NCPA checks work). The agent is reporting the following errors. { "swap": { "total": "Error retrieving child: 'PdhAddEnglishCounterW failed. Performance counters may be disabled.'", "free": "Error retrieving child: 'PdhAddEnglishCounterW failed. Performance counters may be disabled.'", "percent": "Error retrieving child: 'PdhAddEnglishCounterW failed. Performance counters may be disabled.'", "used": "Error retrieving child: 'PdhAddEnglishCounterW failed. Performance counters may be disabled.'" } }

The check works fine if we remove 2.4.1 and reinstall 2.4.0.

We are currently testing on Windows Server 2019.

sawolf commented 9 months ago

The forum thread for this issue included this log, figured it would be useful over here:


Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app
  File "C:\Python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
  File "C:\Python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
  File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
  File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request
  File "C:\Users\Administrator\Documents\repos\ncpa\agent\listener\server.py", line 310, in token_auth_decoration
  File "C:\Users\Administrator\Documents\repos\ncpa\agent\listener\server.py", line 1121, in api
  File "C:\Users\Administrator\Documents\repos\ncpa\agent\listener\nodes.py", line 99, in run_check
  File "C:\Users\Administrator\Documents\repos\ncpa\agent\listener\nodes.py", line 284, in get_values
  File "C:\Users\Administrator\Documents\repos\ncpa\agent\listener\psapi.py", line 158, in <lambda>
  File "C:\Python27\lib\site-packages\psutil\__init__.py", line 1987, in swap_memory
  File "C:\Python27\lib\site-packages\psutil\_pswindows.py", line 257, in swap_memory
RuntimeError: PdhAddEnglishCounterW failed. Performance counters may be disabled.

For what it's worth, I wasn't able to repro this on either of my available Windows devices, though I didn't try it on Windows Server 2019.

SNapier commented 9 months ago

This issue exists with Windows version upgrades from 2.4.1 to v3 versions as well.

I think it's related to artifacts of the previous versions not being cleaned up in the process.

Try removing the entry for NCPA from WOW64 in the registry for the previous version and rerunning the install after.

--SN

On Wed, Nov 1, 2023 at 11:05 AM Sebastian Wolf @.***> wrote:

The forum thread https://support.nagios.com/forum/viewtopic.php?p=345788 for this issue included this log, figured it would be useful over here:

Traceback (most recent call last): File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app File "C:\Python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request File "C:\Python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request File "C:\Users\Administrator\Documents\repos\ncpa\agent\listener\server.py", line 310, in token_auth_decoration File "C:\Users\Administrator\Documents\repos\ncpa\agent\listener\server.py", line 1121, in api File "C:\Users\Administrator\Documents\repos\ncpa\agent\listener\nodes.py", line 99, in run_check File "C:\Users\Administrator\Documents\repos\ncpa\agent\listener\nodes.py", line 284, in get_values File "C:\Users\Administrator\Documents\repos\ncpa\agent\listener\psapi.py", line 158, in File "C:\Python27\lib\site-packages\psutil__init__.py", line 1987, in swap_memory File "C:\Python27\lib\site-packages\psutil_pswindows.py", line 257, in swap_memory RuntimeError: PdhAddEnglishCounterW failed. Performance counters may be disabled.

— Reply to this email directly, view it on GitHub https://github.com/NagiosEnterprises/ncpa/issues/1000#issuecomment-1789227596, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMCUBVXB6BVSC3QTUUPAI53YCJXOJAVCNFSM6AAAAAA6PGQH2OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBZGIZDONJZGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

shoreypu commented 8 months ago

We were able to resolve the problem by running c:\windows\system32\lodctr /R, as well as, adding Disable Performance Counters value, set it to 0 to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance.

Not sure if just running lodctr /R followed by a reboot would fix this as well.

ne-bbahn commented 8 months ago

I haven't been able to reproduce this particular issue, but I have found that silent installs on Windows aren't logging, so there is definitely something going wrong there.

EDIT: Actually the only issue was the default logging level was set to warning with the silent install, so it was only logging warnings. Logging is fine on silent installs.