[fpc-pascal] How to get info about CPU and Memory usage?
ludo.brands at free.fr
Wed Feb 27 17:47:34 CET 2013
On 02/27/2013 05:25 PM, Krzysztof wrote:
> I need system info such CPU (by PID), memory usage (by PID), free memory
> etc. Target platform: Linux.
> Linux have command line tools like ps, top, memstat, but I'm just
> wondering if Free Pascal has wrappers for these commands. If not, then I
> just get these information by execution external process.
On newer linux kernels, instead of running external processes you can
better read and parse /proc/pid/stat (replace pid with the PID). If you
need per thread info you can read /proc/pid/task/tid/stat. These are
single line pseudo files with space separated values. Much easier than
parsing the free format output from ps, top, etc.
More information about the fpc-pascal