Mercurial > archived > louis > perso > liblxcstats
annotate container.c @ 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 | fe254ba0818d |
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 #include <sys/types.h> |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
2 #include <sys/stat.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 <assert.h> |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
5 #include <dirent.h> |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
6 #include <err.h> |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
7 #include <errno.h> |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
8 #include <stdlib.h> |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
9 #include <string.h> |
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 #include "lxcstats.h" |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
12 #include "_lxcstats.h" |
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 static int |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
15 _lxcst_unselect_current_and_parent(const struct dirent* d) |
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 return (strcmp(d->d_name, ".") && strcmp(d->d_name, "..")); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
18 } |
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 struct lxcst * |
7
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
21 _lxcst_container_new(const struct _lxcst_controller *ct, const char *name) |
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 char buf[256]; |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
24 struct lxcst *c; |
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 assert(ct); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
27 assert(name); |
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 c = calloc(1, sizeof(*c)); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
30 if (!c) |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
31 return (NULL); |
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 _lxcst_join_path(buf, sizeof(buf), ct->cgroup_dir, name); |
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 c->name = strdup(name); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
36 c->cgroup_dir = strdup(buf); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
37 if (!c->name || !c->cgroup_dir) |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
38 goto free_container; |
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 return (c); |
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 free_container: |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
43 free(c->name); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
44 free(c); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
45 return (NULL); |
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 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
48 void |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
49 _lxcst_container_delete(struct lxcst *c) |
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 if (c) { |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
52 free(c->name); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
53 free(c->cgroup_dir); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
54 free(c->cpuacct.percpu); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
55 free(c); |
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 |
7
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
59 /* |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
60 * Should be equivalent to the number of directories found under /var/lib/lxc/ |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
61 */ |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
62 int |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
63 _lxcst_container_count(const struct _lxcst_controller *ct) |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
64 { |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
65 int n; |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
66 struct dirent **c_vec; |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
67 int count; |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
68 char buf[PATH_MAX]; |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
69 |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
70 n = scandir(ct->lxc_dir, &c_vec, &_lxcst_unselect_current_and_parent, NULL); |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
71 if (n != -1) { |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
72 count = n; |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
73 while (n--) { |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
74 if (!_lxcst_isdir(_lxcst_join_path(buf, sizeof(buf), ct->lxc_dir, c_vec[n]->d_name))) |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
75 --count; |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
76 free(c_vec[n]); |
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 free(c_vec); |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
79 return (count); |
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 |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
82 return (-1); |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
83 } |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
84 |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
85 int |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
86 _lxcst_container_read_infos(struct lxcst *c) |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
87 { |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
88 int i; |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
89 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
90 assert(c); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
91 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
92 for (i = 0; _lxcst_probes[i].fn; ++i) |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
93 if (_lxcst_probes[i].fn((c))) |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
94 warn("%s probe failed for container %s", _lxcst_probes[i].name, c->name); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
95 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
96 return (0); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
97 } |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
98 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
99 int |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
100 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
|
101 { |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
102 int n; |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
103 struct dirent **c_vec; |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
104 struct lxcst *c; |
7
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
105 char buf[PATH_MAX]; |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
106 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
107 assert(hdl); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
108 assert(hdl->cgroup_dir); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
109 assert(cb); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
110 |
7
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
111 _lxcst_globals_reset(); |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
112 |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
113 n = scandir(hdl->cgroup_dir, &c_vec, &_lxcst_unselect_current_and_parent, NULL); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
114 if (n > 0) { |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
115 while (n--) { |
7
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
116 if (_lxcst_isdir(_lxcst_join_path(buf, sizeof(buf), hdl->cgroup_dir, c_vec[n]->d_name))) { |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
117 c = _lxcst_container_new(hdl, c_vec[n]->d_name); |
7
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
118 _lxcst_globals.running_containers++; |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
119 if (c && _lxcst_container_read_infos(c) == 0 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
120 && cb(ctx, c)) { |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
121 errno = EINTR; |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
122 goto abort_by_cb; |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
123 } |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
124 } |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
125 free(c_vec[n]); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
126 } |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
127 free(c_vec); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
128 } else if (n < 0) { |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
129 return (-1); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
130 } |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
131 |
7
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
132 n = _lxcst_container_count(hdl); |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
133 if (n == -1) { |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
134 warn("can't get the total number of containers"); |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
135 return (-1); |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
136 } |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
137 |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
138 _lxcst_globals.stopped_containers = n - _lxcst_globals.running_containers; |
8339ab15527d
Add running/stopped containers global statistics and refactor some things
Louis Opter <louis@dotcloud.com>
parents:
3
diff
changeset
|
139 |
0
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
140 return (0); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
141 |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
142 abort_by_cb: |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
143 free(c_vec[n + 1]); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
144 while (n--) |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
145 free(c_vec[n]); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
146 free(c_vec); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
147 return (-1); |
6ce4443e7545
Add the draft of an API to collect statistics on LXC
Louis Opter <kalessin@kalessin.fr>
parents:
diff
changeset
|
148 } |