Mercurial > archived > louis > perso > liblxcstats
annotate _lxcstats.h @ 6:e2b88f50e136
cpuacct: replace strtoll by strtoul and replace sscanf by strsplit + strtoul
author | Louis Opter <louis@dotcloud.com> |
---|---|
date | Sat, 01 Jan 2011 16:18:17 +0100 |
parents | 50215911acb3 |
children | 8339ab15527d |
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_PRIV_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_PRIV_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 "compat/compat.h" |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
5 # include "probes/probes.h" |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
6 |
6
e2b88f50e136
cpuacct: replace strtoll by strtoul and replace sscanf by strsplit + strtoul
Louis Opter <louis@dotcloud.com>
parents:
4
diff
changeset
|
7 # define NSEC_PER_SEC 1000000000L |
e2b88f50e136
cpuacct: replace strtoll by strtoul and replace sscanf by strsplit + strtoul
Louis Opter <louis@dotcloud.com>
parents:
4
diff
changeset
|
8 |
e2b88f50e136
cpuacct: replace strtoll by strtoul and replace sscanf by strsplit + strtoul
Louis Opter <louis@dotcloud.com>
parents:
4
diff
changeset
|
9 # define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) |
3
2cb8a6cbe468
cpuacct: convert per cpu usage from nanoseconds to jiffies
Louis Opter <louis@dotcloud.com>
parents:
0
diff
changeset
|
10 |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
11 struct dirent; |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
12 |
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 * Store all informations needed to get statistics from a cgroup |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
15 * hierarchy. |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
16 */ |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
17 struct _lxcst_controller { |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
18 char *cgroup_dir; /**< Mount point of the cgroup hierarchy. */ |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
19 }; |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
20 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
21 /** |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
22 * Allocate a new lxcst structure for the given container. |
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 struct lxcst *_lxcst_container_new(struct _lxcst_controller *, const char *); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
25 |
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 * Free a lxcst structure. |
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 void _lxcst_container_delete(struct lxcst *); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
30 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
31 /** |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
32 * Get statistics on a container. |
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 int _lxcst_container_read_infos(struct lxcst *); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
35 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
36 char *_lxcst_join_path(char *, size_t , const char *, const char *); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
37 |
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 * Used to select only directories with scandir. We can't directly use it with |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
40 * scandir because we need the cgroup_dir. |
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 * @return true if the given directory entry is a directory. |
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 int _lxcst_isdir(const struct _lxcst_controller *, const struct dirent *); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
45 |
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 * Allocate a buffer and read an entire file in it. |
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 * @param [in] path Path to the file to read |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
50 * @param [out] content A pointer to a pointer which will hold the allocated |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
51 * buffer. |
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 * @return The size of the buffer on sucess, -1 with errno set otherwise. |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
54 */ |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
55 ssize_t _lxcst_read_file(const char *path, char **content); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
56 |
4
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
57 /** |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
58 * Split a string around spaces (defined by isspace()). |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
59 * |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
60 * @param [in] str The string to split, spaces are erased with '\0'. |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
61 * @param [out] fields An array of string, each entry will point to a word of |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
62 * the string. |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
63 * @param [in] nfields Number of entries into the fields array. |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
64 * |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
65 * @return The number of fields found. |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
66 */ |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
67 int _lxcst_strsplit(char *str, char **fields, size_t nfields); |
50215911acb3
Add a strsplit() function and stop to build probes into a separate library
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
68 |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
69 #endif |