Reporting of current open files global counter on system as part of device stats
General
Several memory leaks were discovered and fixed in the development phase. The main reason we haven’t noticed them before is because we currently don’t monitor related system resources. Relatively small code-base changes committed under this feature aim at bridging this gap by adding two additional counters to the device report stats.
The two counters are used_file_handles
and total_file_handles
marking the used and available file handles (in Linux terminology), respectively. More generally, the first counter and second counter are intended to track system file/memory resources that are currently used and the total amount of resources available, respectively.
Cloud interaction
No changes envisioned for cloud interaction. If device stats are enabled (in the same manner as before), two new counters are included in the report.
Northbound API
Two new fields were added to the src/lib/protobuf/opensync_stats.proto
:
message Device {
...
optional PowerInfo powerInfo = 11;
+ optional uint32 used_file_handles = 12;
+ optional uint32 total_file_handles = 13;
}
Southbound API
The counters are only populated meaningfully when Linux-target layersrc/lib/target/src/target_linux.c
is linked into the image. The function definition below follows a standard pattern in the target layer – it reads from the appropriate file from the sysfs (namely /proc/sys/fs/file-nr
and stores the retrieved values.
static bool linux_device_file_handles_get(dpp_device_record_t *record)
Some standard minor changes were introduced in the lib/datapipeline
to store the retrieved values in the correct protobuf structure.
Requirements
Current implementation supports Linux platforms under the assumption the /proc/sys/fs/file-nr
exists and can be read from by the SM process.