start a cpuinfo example

This commit is contained in:
Doug MacEachern 2008-03-05 06:31:33 +00:00
parent da6d72a31e
commit 0aed0d800e
1 changed files with 30 additions and 0 deletions

30
examples/cpuinfo.c Normal file
View File

@ -0,0 +1,30 @@
#include <stdio.h>
#include "sigar.h"
int main(int argc, char **argv) {
int status, i;
sigar_t *sigar;
sigar_cpu_list_t cpulist;
sigar_open(&sigar);
status = sigar_cpu_list_get(sigar, &cpulist);
if (status != SIGAR_OK) {
printf("cpu_list error: %d (%s)\n",
status, sigar_strerror(sigar, status));
exit(1);
}
for (i=0; i<cpulist.number; i++) {
sigar_cpu_t cpu = cpulist.data[i];
/*...*/
}
sigar_cpu_list_destroy(sigar, &cpulist);
sigar_close(sigar);
return 0;
}