system-load-plugin-0.1.0

Martti Kuparinen martti.kuparinen at iki.fi
Wed Jul 2 07:42:24 CEST 2003


Riccardo Persichetti wrote:
>
> As the name implies, it's an xfce4 plugin that monitors the
> current system load.
> At the moment it needs the "/proc/stat" file in order to work,

Why don't you use getloadavg(3)? This would work even in xBSD...
Here's a small sample, tested on Linux and FreeBSD:


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
     double loadavg[3];

     if (getloadavg(loadavg, sizeof(loadavg) / sizeof(loadavg[0])) < 0) {
         perror("getloadavg");
         exit(1);
     }
     printf("Current load: %.2f\n", loadavg[0]);
     return 0;
}


Martti




More information about the Xfce4-dev mailing list