comparison lxcstats.h @ 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 #ifndef _LXC_STATS_H_
2 # define _LXC_STATS_H_
3
4 # include <stdint.h>
5
6 /**
7 * Opaque structure used as a context for all liblxcst functions.
8 */
9 typedef struct _lxcst_controller lxcst_handle;
10
11 /**
12 * This structure contains available statistics on a container.
13 */
14 struct lxcst {
15 char *name; /*< Name of the container */
16 char *cgroup_dir;/*< cgroup directory of the container */
17 struct {
18 uint32_t user; /*< CPU time spent in userland */
19 uint32_t system; /*< CPU time spent in kernelland */
20 uint64_t *percpu; /*< CPU time per CPU (zero-terminated array or NULL) */
21 } cpuacct;
22 };
23
24 /**
25 * This structure contains globals statistics on LXC.
26 *
27 * Note: see how lxc-info gets these infos.
28 */
29 struct lxcst_globals {
30 uint32_t running_containers;
31 uint32_t stopped_containers;
32 };
33
34 /**
35 * @brief Initialize the library.
36 *
37 * @return A pointer to an opaque structure which can be free'd with free
38 * or NULL on failure with errno set.
39 *
40 * @see lxcst_close
41 */
42 lxcst_handle *lxcst_open(void);
43
44 /**
45 * @brief Close the library.
46 *
47 * @param [in] hdl The pointer returned by lxcst_open.
48 *
49 * @return 0 on success, -1 if an error occured with errno set.
50 */
51 int lxcst_close(lxcst_handle *hdl);
52
53 /**
54 * @brief Collect statistic on all containers.
55 *
56 * @param [in] hdl The pointer returned by lxcst_handle.
57 * @param [in] cb A function pointer to a callback which takes a pointer to an
58 * user context and a pointer to lxcst structure.
59 * @param [in] ctx A pointer to an user defined variable which will be used as
60 * an argument to the callback. If the callback returns non zero
61 * lxcst_span_containers stops and return with -1 with errno set to EINTR.
62 *
63 * @return 0 on success, -1 on error with errno set.
64 */
65 int lxcst_span_containers(lxcst_handle *hdl, int (*cb)(void *, const struct lxcst *), void *ctx);
66
67 #endif