Open ccztux opened 1 year ago
Hi, let me share findings:
In "server.py" there is node = psapi.getter(...
call within the "api()" funtion which triggers the corresponding function from psapi.py. That function runs
if not cache:
refresh(config)
which initializes the global object "root":
def refresh(config, path):
global root
root = get_root_node(config)
return True
but the "get_root_node()" functions runs all the cpu, mem, disk, etc. node generators no matter which API path was actually called each time any /api/* request was triggered.
What about passing the "path" trough "refresh()" to "get_root_node()" and process only that part?
I believe this issue deserves a higher priority due to its impacts.
Every single check causes ncpa to get all available data from the system which is inefficient.
For analyzing and to show the issue i have added some additional log messages.
I have executed this single check:
Which results in (log ouptut):
This also happens in the GUI on the following endpoints:
https://localhost:5693/gui/stats
https://localhost:5693/gui/graphs
For
https://localhost:5693/gui/top
only the relevant data will be collected by ncpa which is fine: https://github.com/NagiosEnterprises/ncpa/blob/9ef1e7e9fce6d640dcfc94da116b7b912403910f/agent/listener/server.py#L833-L846