comparison _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 e2b88f50e136
children
comparison
equal deleted inserted replaced
6:e2b88f50e136 7:8339ab15527d
3 3
4 # include "compat/compat.h" 4 # include "compat/compat.h"
5 # include "probes/probes.h" 5 # include "probes/probes.h"
6 6
7 # define NSEC_PER_SEC 1000000000L 7 # define NSEC_PER_SEC 1000000000L
8
9 # define LXC_DIR "/var/lib/lxc/"
8 10
9 # define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) 11 # define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
10 12
11 struct dirent; 13 struct dirent;
12 14
13 /** 15 /**
14 * Store all informations needed to get statistics from a cgroup 16 * Store all informations needed to get statistics from a cgroup
15 * hierarchy. 17 * hierarchy.
16 */ 18 */
17 struct _lxcst_controller { 19 struct _lxcst_controller {
18 char *cgroup_dir; /**< Mount point of the cgroup hierarchy. */ 20 char *cgroup_dir; /**< Mount point of the cgroup hierarchy. */
21 const char *lxc_dir; /**< LXC configuration directory (LXC_DIR). */
19 }; 22 };
23
24 extern struct lxcst_globals _lxcst_globals;
20 25
21 /** 26 /**
22 * Allocate a new lxcst structure for the given container. 27 * Allocate a new lxcst structure for the given container.
23 */ 28 */
24 struct lxcst *_lxcst_container_new(struct _lxcst_controller *, const char *); 29 struct lxcst *_lxcst_container_new(const struct _lxcst_controller *, const char *);
25 30
26 /** 31 /**
27 * Free a lxcst structure. 32 * Free a lxcst structure.
28 */ 33 */
29 void _lxcst_container_delete(struct lxcst *); 34 void _lxcst_container_delete(struct lxcst *);
30 35
31 /** 36 /**
37 * Get the total number of LXC containers on this machine.
38 */
39 int _lxcst_container_count(const struct _lxcst_controller *ct);
40
41 /**
32 * Get statistics on a container. 42 * Get statistics on a container.
33 */ 43 */
34 int _lxcst_container_read_infos(struct lxcst *); 44 int _lxcst_container_read_infos(struct lxcst *);
35 45
46 /**
47 * Reset the global statistics structure.
48 */
49 void _lxcst_globals_reset(void);
50
36 char *_lxcst_join_path(char *, size_t , const char *, const char *); 51 char *_lxcst_join_path(char *, size_t , const char *, const char *);
37 52
38 /** 53 /**
39 * Used to select only directories with scandir. We can't directly use it with 54 * @return true if the given path is a directory.
40 * scandir because we need the cgroup_dir.
41 *
42 * @return true if the given directory entry is a directory.
43 */ 55 */
44 int _lxcst_isdir(const struct _lxcst_controller *, const struct dirent *); 56 int _lxcst_isdir(const char *);
45 57
46 /** 58 /**
47 * Allocate a buffer and read an entire file in it. 59 * Allocate a buffer and read an entire file in it.
48 * 60 *
49 * @param [in] path Path to the file to read 61 * @param [in] path Path to the file to read