Mercurial > archived > louis > perso > liblxcstats
comparison tests/span_containers.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 | 8339ab15527d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6ce4443e7545 |
---|---|
1 #include <err.h> | |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
4 | |
5 #include "lxcstats.h" | |
6 | |
7 unsigned int n = 0; | |
8 | |
9 int | |
10 cb(void *ctx, const struct lxcst *container) | |
11 { | |
12 if (ctx) | |
13 errx(EXIT_FAILURE, "ctx must be NULL"); | |
14 | |
15 if (!container) | |
16 errx(EXIT_FAILURE, "container must not be NULL"); | |
17 | |
18 ++n; | |
19 | |
20 return (0); /* continue */ | |
21 } | |
22 | |
23 int | |
24 main(int argc, char *argv[]) | |
25 { | |
26 lxcst_handle *hdl; | |
27 | |
28 hdl = lxcst_open(); | |
29 if (!hdl) | |
30 err(EXIT_FAILURE, "lxcst_open failed"); | |
31 | |
32 lxcst_span_containers(hdl, &cb, NULL); | |
33 | |
34 lxcst_close(hdl); | |
35 | |
36 printf("%s: spanned %d containers.\n", *argv, n); | |
37 | |
38 return (EXIT_SUCCESS); | |
39 (void)argc; | |
40 } |