Mercurial > archived > louis > perso > liblxcstats
view probes/tests/cpuacct.c @ 0:6ce4443e7545
Add the draft of an API to collect statistics on LXC
author | Louis Opter <kalessin@kalessin.fr> |
---|---|
date | Wed, 29 Dec 2010 23:28:14 +0100 |
parents | |
children | 2cb8a6cbe468 |
line wrap: on
line source
#include <sys/types.h> #include <err.h> #include <stdlib.h> #include <stdio.h> #include "lxcstats.h" #include "_lxcstats.h" #include "probes/probes.h" int main(void) { lxcst_handle *hdl; struct lxcst *c; int i; hdl = lxcst_open(); if (!hdl) err(EXIT_FAILURE, "lxcst_open failed"); c = _lxcst_container_new(hdl, "."); if (!c) err(EXIT_FAILURE, "cant create container"); if (_lxcst_probe_cpuacct(c)) err(EXIT_FAILURE, "probe cpuacct failed"); printf("user %d\nsystem %d\n", c->cpuacct.user, c->cpuacct.system); for (i = 0; c->cpuacct.percpu[i]; ++i) printf("cpu[%d] %lu\n", i, c->cpuacct.percpu[i]); _lxcst_container_delete(c); lxcst_close(hdl); return (EXIT_SUCCESS); }