1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
I. BUILDING
-------------------------
1. Requirements:
libfcgi - http://www.nongnu.org/fastcgi/
libcgroup - http://libcg.sourceforge.net/
2. Preconfigure if using git clone (with autoconf & automake)
# autoreconf -fiv
3. Configure and make
# ./configure --enable-debug
# make
II. RUNNING
-------------------------
1. For lighttpd use
fastcgi.server = (
"/fcgi/" =>
((
"host" => "127.0.0.1",
"port" => "9000",
"check-local" => "disable",
))
)
2. Run ./fcgi from the directory where is was built
# ./fcgi
2014-01-18 17:06:28 +0400 main.c:193 (init_libraries): initializing libfcgi
2014-01-18 17:06:28 +0400 main.c:200 (init_libraries): initializing libcgroup
./fcgi: socket `:9000', backlog 16, 5 workers, URI prefix `/fcgi'
2014-01-18 17:06:28 +0400 main.c:230 (main): allocating space for 5 threads
2014-01-18 17:06:28 +0400 main.c:239 (main): starting threads
2014-01-18 17:06:28 +0400 main.c:245 (main): starting thread #0
2014-01-18 17:06:28 +0400 main.c:245 (main): starting thread #1
2014-01-18 17:06:28 +0400 main.c:63 (worker): thread #0 started
2014-01-18 17:06:28 +0400 main.c:245 (main): starting thread #2
2014-01-18 17:06:28 +0400 main.c:63 (worker): thread #1 started
2014-01-18 17:06:28 +0400 main.c:245 (main): starting thread #3
2014-01-18 17:06:28 +0400 main.c:63 (worker): thread #2 started
2014-01-18 17:06:28 +0400 main.c:245 (main): starting thread #4
2014-01-18 17:06:28 +0400 main.c:63 (worker): thread #3 started
2014-01-18 17:06:28 +0400 main.c:63 (worker): thread #4 started
III. API
-------------------------
0. Setup used in examples:
# lscgroup
cpu:/
cpu:/hello
cpu:/hello/world
blkio:/
blkio:/hello
blkio:/hello/man
cpuacct,devices,freezer:/
net_cls,perf_event:/
1. List all groups hierarhies
# curl 'http://localhost/fcgi/cgroups/'
[
{controllers: ["cpu"], groups: ["/", "/hello", "/hello/world"]},
{controllers: ["blkio"], groups: ["/", "/hello", "/hello/man"]},
{controllers: ["cpuacct", "devices", "freezer"], groups: ["/"]},
{controllers: ["net_cls", "perf_event"], groups: ["/"]}
]
2. List particular hierarhies
# curl 'http://localhost/fcgi/cgroups/cpu:/'
[{controllers: ["cpu"], groups: ["/", "/hello", "/hello/world"]}]
# curl 'http://localhost/fcgi/cgroups/cpu,blkio:/'
[{controllers: ["cpu"], groups: ["/", "/hello", "/hello/world"]},
{controllers: ["blkio"], groups: ["/", "/hello", "/hello/man"]}]
# curl 'http://localhost/fcgi/cgroups/cpu,blkio:/hello'
[{controllers: ["cpu"], groups: ["/hello/", "/hello/world"]},
{controllers: ["blkio"], groups: ["/hello/", "/hello/man"]}]
# curl 'http://localhost/fcgi/cgroups/cpu,devices:/hello'
[{controllers: ["cpu"], groups: ["/hello/", "/hello/world"]}]
3. Listing tasks
# curl 'http://localhost/fcgi/cgroups/blkio:/hello?list-tasks'
[24086]
# curl 'http://localhost/fcgi/cgroups/cpu:/hello?list-tasks'
[1, 24086, 24099]
# curl 'http://localhost/fcgi/cgroups/cpu,blkio:/hello?list-tasks'
[24086]
4. Attaching (moving) a task to a group
# curl 'http://localhost/fcgi/cgroups/blkio:/hello?attach-task=24099'
{}
# curl 'http://localhost/fcgi/cgroups/cpu,blkio:/hello?list-tasks'
[24086, 24099]
|