Mercurial > archived > louis > perso > liblxcstats
annotate lxcstats.h @ 12:dbf24a82f625 default tip
Fix doxygen comments and add a Doxyfile
author | Louis Opter <kalessin@kalessin.fr> |
---|---|
date | Fri, 07 Jan 2011 21:49:31 +0100 |
parents | cff6be97dae1 |
children |
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 /** |
11
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
7 * @mainpage liblxcstats API Reference |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
8 * |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
9 * @section sec_about About |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
10 * |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
11 * The liblxcstats returns resources usage statistics on the LXC Containers |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
12 * found on your system in a convenient data structure. LXC, Linux Containers, |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
13 * are like chroots on steroids. |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
14 * |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
15 * LXC uses the cgroup Linux kernel feature. Unlike other software |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
16 * virtualization technique (such as OpenVZ), LXC works on a vanilla Linux |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
17 * kernel. |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
18 * |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
19 * The code assumes that the cgroup hierarchy has been created by LXC. In the |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
20 * future this library could become a generic cgroup statistics library. |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
21 * |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
22 * This library is used to implement the LXC plugin for Collectd. |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
23 * |
12
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
24 * @section sec_api API |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
25 * |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
26 * The lxcstats.h header contains everything you need. |
11
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
27 * |
12
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
28 * @section sec_see_also See Also |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
29 * |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
30 * - <a href="http://lxc.sourceforge.net/">LXC — Linux Containers</a>; |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
31 * - <a href="http://collectd.org/">Collectd — The system statistics collection daemon</a>. |
11
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
32 */ |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
33 |
cff6be97dae1
Add a mainpage for the doxygen documentation
Louis Opter <kalessin@kalessin.fr>
parents:
9
diff
changeset
|
34 /** |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
35 * 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
|
36 */ |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
37 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
|
38 |
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 * 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
|
41 */ |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
42 struct lxcst { |
12
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
43 char *name; /**< Name of the container */ |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
44 char *cgroup_dir;/**< cgroup directory of the container */ |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
45 struct { |
12
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
46 uint32_t user; /**< CPU time spent in userland */ |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
47 uint32_t system; /**< CPU time spent in kernelland */ |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
48 uint32_t *percpu; /**< CPU time per CPU (zero-terminated array or NULL) */ |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
49 } cpuacct; /**< CPU accounting in USER_HZ */ |
9 | 50 struct { |
12
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
51 uint64_t used; /**< RAM used by applications */ |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
52 uint64_t mapped; /**< RAM used for mapped file (includes tmpfs/shmem) */ |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
53 uint64_t cached; /**< RAM cached by the kernel */ |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
54 uint64_t swapped; /**< SWAP used */ |
dbf24a82f625
Fix doxygen comments and add a Doxyfile
Louis Opter <kalessin@kalessin.fr>
parents:
11
diff
changeset
|
55 } memory; /**< Memory accounting in bytes */ |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
56 }; |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
57 |
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 * 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
|
60 * |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
61 * 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
|
62 */ |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
63 struct lxcst_globals { |
7
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
64 uint16_t running_containers; |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
65 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
|
66 }; |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
67 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
68 /** |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
69 * @brief Initialize the library. |
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 * @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
|
72 * 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
|
73 * |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
74 * @see lxcst_close |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
75 */ |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
76 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
|
77 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
78 /** |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
79 * @brief Close the library. |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
80 * |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
81 * @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
|
82 * |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
83 * @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
|
84 */ |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
85 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
|
86 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
87 /** |
7
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
88 * @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
|
89 * |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
90 * 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
|
91 * 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
|
92 * |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
93 * @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
|
94 * @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
|
95 * 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
|
96 * @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
|
97 * 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
|
98 * 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
|
99 * |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
100 * @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
|
101 * |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
102 * @see lxcst_globals_statistics |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
103 * @see struct lxcst |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
104 */ |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
105 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
|
106 |
7
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
107 /** |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
108 * @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
|
109 * |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
110 * @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
|
111 * |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
112 * @see struct lxcst_globals |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
113 * @see lxcst_span_containers |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
114 */ |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
115 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
|
116 |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
117 #endif |