annotate lxcstats.h @ 7:8339ab15527d

Add running/stopped containers global statistics and refactor some things
author Louis Opter <louis@dotcloud.com>
date Sat, 01 Jan 2011 17:46:40 +0100
parents 2cb8a6cbe468
children 6f2e13f5fcfd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
1 #ifndef _LXC_STATS_H_
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
2 # define _LXC_STATS_H_
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
3
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
4 # include <stdint.h>
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
5
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
6 /**
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
7 * Opaque structure used as a context for all liblxcst functions.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
8 */
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
9 typedef struct _lxcst_controller lxcst_handle;
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
10
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
11 /**
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
12 * This structure contains available statistics on a container.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
13 */
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
14 struct lxcst {
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
15 char *name; /*< Name of the container */
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
16 char *cgroup_dir;/*< cgroup directory of the container */
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
17 struct {
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
18 uint32_t user; /*< CPU time spent in userland */
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
19 uint32_t system; /*< CPU time spent in kernelland */
3
2cb8a6cbe468 cpuacct: convert per cpu usage from nanoseconds to jiffies
Louis Opter <louis@dotcloud.com>
parents: 0
diff changeset
20 uint32_t *percpu; /*< CPU time per CPU (zero-terminated array or NULL) */
2cb8a6cbe468 cpuacct: convert per cpu usage from nanoseconds to jiffies
Louis Opter <louis@dotcloud.com>
parents: 0
diff changeset
21 } cpuacct; /*< CPU accounting in USER_HZ */
0
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
22 };
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
23
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
24 /**
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
25 * This structure contains globals statistics on LXC.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
26 *
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
27 * Note: see how lxc-info gets these infos.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
28 */
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
29 struct lxcst_globals {
7
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
30 uint16_t running_containers;
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
31 uint16_t stopped_containers;
0
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
32 };
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
33
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
34 /**
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
35 * @brief Initialize the library.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
36 *
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
37 * @return A pointer to an opaque structure which can be free'd with free
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
38 * or NULL on failure with errno set.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
39 *
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
40 * @see lxcst_close
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
41 */
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
42 lxcst_handle *lxcst_open(void);
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
43
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
44 /**
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
45 * @brief Close the library.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
46 *
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
47 * @param [in] hdl The pointer returned by lxcst_open.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
48 *
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
49 * @return 0 on success, -1 if an error occured with errno set.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
50 */
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
51 int lxcst_close(lxcst_handle *hdl);
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
52
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
53 /**
7
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
54 * @brief Collect statistics on all containers.
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
55 *
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
56 * Walk the cgroup pseudo filesystem and get statistics for all found
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
57 * containers. Also refresh the global statistics struture.
0
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
58 *
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
59 * @param [in] hdl The pointer returned by lxcst_handle.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
60 * @param [in] cb A function pointer to a callback which takes a pointer to an
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
61 * user context and a pointer to lxcst structure.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
62 * @param [in] ctx A pointer to an user defined variable which will be used as
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
63 * an argument to the callback. If the callback returns non zero
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
64 * lxcst_span_containers stops and return with -1 with errno set to EINTR.
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
65 *
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
66 * @return 0 on success, -1 on error with errno set.
7
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
67 *
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
68 * @see lxcst_globals_statistics
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
69 * @see struct lxcst
0
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
70 */
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
71 int lxcst_span_containers(lxcst_handle *hdl, int (*cb)(void *, const struct lxcst *), void *ctx);
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
72
7
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
73 /**
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
74 * @brief Get a copy of the global LXC statistics object.
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
75 *
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
76 * @param [out] sb A pointer to a struct lxcst_globals.
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
77 *
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
78 * @see struct lxcst_globals
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
79 * @see lxcst_span_containers
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
80 */
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
81 void lxcst_globals_statistics(struct lxcst_globals *sb);
8339ab15527d Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents: 3
diff changeset
82
0
6ce4443e7545 Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff changeset
83 #endif