comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:6ce4443e7545
1 #include <sys/types.h>
2
3 #include <err.h>
4 #include <stdlib.h>
5 #include <stdio.h>
6
7 #include "lxcstats.h"
8 #include "_lxcstats.h"
9 #include "probes/probes.h"
10
11 int
12 main(void)
13 {
14 lxcst_handle *hdl;
15 struct lxcst *c;
16 int i;
17
18 hdl = lxcst_open();
19 if (!hdl)
20 err(EXIT_FAILURE, "lxcst_open failed");
21
22 c = _lxcst_container_new(hdl, ".");
23 if (!c)
24 err(EXIT_FAILURE, "cant create container");
25
26 if (_lxcst_probe_cpuacct(c))
27 err(EXIT_FAILURE, "probe cpuacct failed");
28
29 printf("user %d\nsystem %d\n", c->cpuacct.user, c->cpuacct.system);
30 for (i = 0; c->cpuacct.percpu[i]; ++i)
31 printf("cpu[%d] %lu\n", i, c->cpuacct.percpu[i]);
32
33 _lxcst_container_delete(c);
34
35 lxcst_close(hdl);
36
37 return (EXIT_SUCCESS);
38 }