miskcoo / ugreen_leds_controller

An LED Controller for UGREEN's DX/DXP NAS Series
179 stars 26 forks source link

Add an optional compiled disk activities monitor to reduce the CPU usage #38

Closed miskcoo closed 3 weeks ago

miskcoo commented 3 weeks ago

This is an optional feature to reduce the CPU usage when monitoring the disk activities. The current bash implementation gives too many forks and use around 1% CPU times, which is also reported in #8, #10 and #34.

This PR replaces the bash version to a C++ version, and you need to do the following to enable it:

# compile the disk activities monitor
g++ -std=c++17 -O2 scripts/blink-disk.cpp -o ugreen-blink-disk

# copy the binary file (the path can be changed, see BLINK_MON_PATH in ugreen-leds.conf)
cp ugreen-blink-disk /usr/bin

# copy the new script and restart the service
cp scripts/ugreen-diskiomon /usr/bin
systemctl restart ugreen-diskiomon

See #34 for further discussions and a test of the performance.