NagiosEnterprises / ncpa

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

get_interface_node is inefficient #1001

Open graham-collinson opened 9 months ago

graham-collinson commented 9 months ago

get_interface_node in agent/listener/psapi.py is inefficient. It calls ps.net_io_counters to get the list of interfaces and then calls make_if_nodes for each interface. make_if_nodes then calls ps.net_io_counters. This leads to n+1 calls to ps.net_io_counters ps.net_io_counters reads from /proc/net/dev for every call. On a server with a few hundred lines in /proc/net/dev (due to having a lot of VLANs) and reading it a few hundred times it can lead to a delay of a few seconds.

Coupled with the problem of all data being gathered for every call (https://github.com/NagiosEnterprises/ncpa/issues/911) this causes delays for every check run against the host

could the code be changed to keep the result of one call to ps.net_io_counters and use that to make_if_nodes?