NagiosEnterprises/ncpa

NCPA Agent failing in OPenVZ or Virtuozzo servers

Opened this issue · 6 comments

The NCPA agent is throwing the error "UNKNOWN: An error occurred connecting to API. (HTTP error: '500 INTERNAL SERVER ERROR') " error on Nagios system. Further checking the ncpa_listener.log, it is throwing the following errors:

2024-04-02 16:38:32,174 geventwebsocket.handler INFO ::ffff:x.x.x.x - - [2024-04-02 16:38:32] "GET /api/memory/swap/?token=********&units=G&warning=90&critical=95&check=1 HTTP/1.1" 500 2551 0.007564
2024-04-02 16:39:38,898 listener INFO before_request() - request.url: https://x.x.x.x:5693/api/system/agent_version/?token=********&check=1
2024-04-02 16:39:38,900 listener.server ERROR Exception on /api/system/agent_version/ [GET]
Traceback (most recent call last):
  File "listener/psapi.py", line 417, in get_root_node
  File "listener/psapi.py", line 325, in get_disk_node
  File "psutil/__init__.py", line 2115, in disk_io_counters
  File "psutil/_pslinux.py", line 1218, in disk_io_counters
NotImplementedError: /proc/diskstats nor /sys/block filesystem are available on this system

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "flask/app.py", line 1463, in wsgi_app
  File "flask/app.py", line 872, in full_dispatch_request
  File "flask/app.py", line 870, in full_dispatch_request
  File "flask/app.py", line 855, in dispatch_request
  File "listener/server.py", line 313, in token_auth_decoration
  File "listener/server.py", line 1104, in api
  File "listener/psapi.py", line 506, in getter
  File "listener/psapi.py", line 487, in refresh
  File "listener/psapi.py", line 420, in get_root_node
  File "logging/__init__.py", line 2123, in exception
  File "logging/__init__.py", line 2115, in error
  File "logging/__init__.py", line 1518, in error
  File "logging/__init__.py", line 1634, in _log
  File "logging/__init__.py", line 1644, in handle
  File "logging/__init__.py", line 1706, in callHandlers
  File "logging/__init__.py", line 974, in handle
  File "logging/__init__.py", line 832, in filter
  File "ncpa.py", line 56, in tokenFilter
TypeError: argument of type 'NotImplementedError' is not iterable
2024-04-02 16:39:38,904 geventwebsocket.handler INFO ::ffff:x.x.x.x - - [2024-04-02 16:39:38] "GET /api/system/agent_version/?token=********&check=1 HTTP/1.1" 500 2551 0.006409

The server has CentOS 7.9 OS installed.

# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)
[root@silicon ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/simfs      1.8T  661G  1.2T  37% /
# ls -lah /proc/diskstats
ls: cannot access /proc/diskstats: No such file or directory

The VPS server is built using the OpenVZ or Virtuozzo platform, which doesn't have /proc/diskstats files so any patch version or solution available to mitigate this case.

Any help would be appreciable.

Thanks,

Hello @iamfasal,

This is an issue with the PSUtil library where if it can't find the right file systems, it throws an error. This error was not being handled, but now should be handled in NCPA 3.1.0.

Hello @ne-bbahn May I know when this v3.1.0 will be released? Does it resolve this issue completely and would be able monitor the resource usages correctly (like CPU, Memory, Swap, Disk, etc.)?

Thanks for the heads up 🙂

Does it resolve this issue completely and would be able monitor the resource usages correctly (like CPU, Memory, Swap, Disk, etc.)?

This will resolve the crashing, but if those filesystems don't exist then PSUtil won't be able to find them and NCPA won't be able to get the information.

@ne-bbahn Does this mean NCPA agent won't work in OpenVZ/Virtuozzo containers? If not, is there any work around to monitor Simfs file systems correctly in OpenVZ/Virtuozzo containers?

@ne-bbahn Does this mean NCPA agent won't work in OpenVZ/Virtuozzo containers? If not, is there any work around to monitor Simfs file systems correctly in OpenVZ/Virtuozzo containers?

I'm not sure exactly what will work in OpenVZ/Virtuozzo containers as I haven't really dug that deep into the PSUtil library and am not familiar with OpenVZ/Virtuozzo containers. Have you checked whether /proc/diskstats and /sys/block exist and if it's just a permissions issue?

@ne-bbahn Those files doesn't even exists in the OpenVZ/Virtuozzo vps servers. Please review the snippets in my initial message which has outputs.

Any solutions for such file systems?