LibGTop is a library used to get system specific data such as CPU, memory usage and info about running processes.
Since it’s part of the GNOME desktop environment, it’s used by some system monitor applets, but it’s main interface is completely independent, so it can be used as a standalone library even for embedded system that already use GLib.
Normally, you should debug your system before deployment and be sure that there are no processes with memory leaks or that are consuming more CPU than they should, but sometimes there could be strange conditions in a process that at certain point start to eat too much CPU or just Valgrind doesn’t support your processor.
In these cases, the system needs to be closely monitored and a library like LibGTop with an API that you can easily use could be quite handy.
I normally use Buildroot, but it doesn’t include LibGTop, it seems that Yocto doesn’t have a recipe neither. I’ll try to explain briefly how to cross-build it for an ARM processor that I’m using with the Linaro hard-float toolchain.
First, let’s export common environment variables that make our life easier:
export HOST=arm-linux export BUILD=i386-linux export PREFIX=/home/paguilar/rootfs
Configure remove unneeded things for an embedded system:
CC=arm-linux-gnueabihf-gcc ./configure --host=$HOST --build=$BUILD --prefix=$PREFIX --with-sysroot=$PREFIX --disable-gtk-doc-html --without-examples --without-libiconv-prefix --without-libintl-prefix --without-x
Edit lib/Makefile and set the following variables:
GLIB_CFLAGS = -I/opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/sysroot/usr/include GLIB_LIBS = -L/opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/sysroot/usr/lib -lgobject-2.0 -lglib-2.0
Compile and install:
make make DESTDIR=/home/paguilar/rootfs install
You can have a look at the GLibTop API here.