I love linux - cpulimit

Well after 30 years of working with Linux, and around 10 using it in anger for control system automation, it was a pleasant surprise to stumble across another wee utility to add to our toolset.

cpulimit does exactly what it promises. You pass it a limit value in % of available CPU and a program you want to limit when running.

cpulimit -l 20 -- <my resource hungry program>

On discovering it, I found two great use cases:

One was an LCD digital display with no data interface that I had to read. Linux to the rescue. A combination of some python scripting, FFMPEG, OpenCV, and the ssocr utility, allowed me to reliably rip the data via an IP camera.

Python's watchdog module allowed me to run ffmpeg in the background, writing images to a ramdisk every x seconds while it monitored the ramdisk, and kicked off a callback to perform the OCR, validate the response, and publish the data another python library, MQTT.

The icing on the cake was using cpulimit to let me limit the resources use of an otherwise greedy ffmpeg - used to read the RTSP stream.

(Note: OpenCV could have done the frame capture as well, but ffmpeg gave me the speed and granularity to capture updates comfortably every 2 seconds)

While I was at it, I was able to limit the cpu on a greedy little python script that sat and monitored some GPIO lines.

Anyway, just a wee end of year blog in support Linux - the control system engineer's swiss army knife.